Custom action vbs doesn't run in InstallShield
Hi guys I'm trying to run the below vbs script inside a custom action on an InstallShield.vbs. The script runs fine if i run it on its own, however when i run it inside the msi i get Error1720
I replaced the last line with the hard coded path for the users %HOMESHARE% but i still get the same issue inside the custom action. I need to run it on install only, hence I'm running it in Deffered System Context with NOT Installed as my Installed Sequence just before Install Finalize
I'm really stumped any help would be great
Const OverWriteFiles = True
Set oWSH = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oUserProfilePath = oWSH.Environment("Process")
'Setup the environment variables for %homedrive%, %homepath%, and %clientname%
osystemroot = oWSH.ExpandEnvironmentStrings("%Systemroot%")
sUserHDrive = oUserProfilePath("HOMEDRIVE")
sProfile = oWSH.ExpandEnvironmentStrings("%HOMESHARE%")
'Check to see if the folder "Software Directory" exists in the user's %homedrive% directory
'if it does exist then do Nothing
If oFSO.FolderExists(sUserHDrive & "\Software") Then
With CreateObject("Shell.Application")
.Open(sUserHDrive & "\Software\Software Templates\PPM\PPM Wizard.dot") End With
'If the "Talsico" directory doesn't exist then proceed
Else
'Create the "Talsico" directory
If Not oFSO.FolderExists(sUserHDrive & "\Software") Then
Set objFolder = oFSO.CreateFolder(sUserHDrive & "\Software")
End If
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Program Files (x86)\App Software" , "O:\Software" , OverWriteFiles
Answers (3)
I managed to use my script and amend it slightly to also set the trusted locations on the users profile. I created an advertised icon, that launches the vbscript which does everything.
Few suggestions..
1. You don't have to create the below object twice in your code..
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Program Files (x86)\App Software" , "O:\Software" , OverWriteFiles
2. If oFSO.FolderExists(sUserHDrive & "\Software") Then
With CreateObject("Shell.Application")
.Open(sUserHDrive & "\Software\Software Templates\PPM\PPM Wizard.dot") End With
'If the "Talsico" directory doesn't exist then proceed
Else // Here Else means the folder doesn't exist
'Create the "Talsico" directory
//Again you are checking whether the specified folder is exist or not in else condition itself//
'Create the "Talsico" directory
If Not oFSO.FolderExists(sUserHDrive & "\Software") Then
Set objFolder = oFSO.CreateFolder(sUserHDrive & "\Software")
End If
End If