/build/static/layout/Breadcrumb_cap_w.png

Script to check whether a file / folder exists

Hi,

I am a new to msi script. I am facing a problem. I need to check whether a file exists or not and accordingly needs to update/increment the registry value while installating a product. Can anyone please share a piece of code(script) to find the list of file and accordingly check whehter files exists or not. If exists then update the registry value. The same thing applies to uninstall. i need to check whether file exists or not and accordingly decrement the registry value. if registry value is '0' then delete the file.

Thanks in advance,


/Sudhi

0 Comments   [ + ] Show comments

Answers (3)

Posted by: supergrid 16 years ago
Yellow Belt
0
The following code may be useful to you.
The first time you install an application it creates an entry in the registry.
When you go to reinstall the same application an incremental count is created.
The same code can be used for application uninstalls.
Note: replace MYAPPS with a name more useful to you.

Good Lucj
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
Function Get_ApplicationReg()
On Error Resume Next
Dim tmp
Get_ApplicationInstalled = False
tmp = oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MYAPPS\Installed Applications\" & sfTitle & "\Installed")
If tmp = "True" Then
Get_ApplicationReg = True
End If
End Function
Sub Set_ApplicationReg()
On Error Resume Next
Dim Count
Select Case bApplicationInstalled
Case False
Call oShell.RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\MYAPPS\Installed Applications\" & sfTitle & "\Installed", "True", "REG_SZ")
Case True
Count = oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MYAPPS\Installed Applications\" & sfTitle & "\ReinstallCount")
Count = Count + 1
Call oShell.RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\MYAPPS\Installed Applications\" & sfTitle & "\ReinstallCount", Count, "REG_SZ")
End Select
End Sub

-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
Posted by: anonymous_9363 16 years ago
Red Belt
0
Go to http://www.devguru.com/technologies/vbscript/home.asp. Search for 'FileSystemObject'. In there you'll find 'FileExists' and 'FolderExists' methods and some rather sparse sample code. For more code examples of actually using those methods, try http://www.computerperformance.co.uk/vbscript/index.htm
Posted by: revizor 16 years ago
Third Degree Blue Belt
0
You can also use MSI functionality to minimize VBS scripting if you want.
System Search allows you to search for files/reg/ini settings and extract search result into an MSI property; you can set conditions based on the property values if you'd like to perform some action...
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ