I just purchase AI recently and I am trying to find a way to execute an external vbs file during install. The package will always be the same but the vbs file will change on a per machine basis. Any ideas??? Thanks in advance for your help.
You may use a custom action to launch the script from the target machine.
From a script you can launch another program using:
Set WshShell = CreateObject("WScript.Shell")
WShShell.Run "c:\test.vbs"
That is if you know the location of the file as you said you know. You can also use a Search, if the script is not in a fixed location. Then you will have to use a statement like:
Well I don't know where this script is going to be located. As it is right now we execute the setup package from a remote pc in the network and the name of that pc can vary. How about if I place my custom vbs file at the same location as the package and then some how acquire the app.path of the package then shell the script like you mention before Wscript.run Path & "file.vbs" My questions then would be how can I obtain the location where the package is running from???
You can find the location of the installing package from the SourceDir property. Here is an vbscript example:
Dim SourcePath
SourcePath = Session.Property("SourceDir")
When you install a MSI package from a remote pc, a local copy of that MSI file is created and executed. So, you only need the path of the script from the users machine.
If, on the user machine, the path of the script is fixed, then you can easily use something like:
Wscript.run Path
If not, you must determine the path and set a property with that value. You may use "Search" page -> "New File Search" button. Enter the name of your script, let say: test.vbs
Use the "Add Location">"Folder" button.
For "Path" you can use folder or property. Let say you choose: [ProgramFilesFolder].
Your file may be in a subfolder of what you have selected so you can set a search Depth.
If test.vbs file exist in users "Program Files Folder" (or its subfolders if you specified a depth) then the RESULT_PROPERTY property will contain the full path of the VBS file.
In this case, you will use from your custom action something like:
the vbs file cannot be added to the package otherwise I will end up with 200 AI packages. The vbs file is unique per client and will need to stay outside the package nor it cannot be copied local to the machine. This vbs file will leave at the server with all the rest of the files. You said that if I run the AI package from a remote machine that it creates a local copy then it will execute and that's fine. What I need then is a way to go back to the remote machine and execute my vbs file. I have also tried this
Dim SourcePath
SourcePath = Session.Property("SourceDir") like you recommended but it returns nothing.
You can launch a program from a server only if you know its full path and the user has access to that file. If the VBS file is not on the user machine then you can use a command like:
WShShell.Run "\\YourServer\USER1\script.vbs"
If this file path/name is different for each user you will have to create that path based on the user/computer name. You can use the properties: USERNAME, ComputerName.
Here is an example that supposes every user has a folder with his/her name on the server, where the script that you want to be launched is located:
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
Dim FullPath
FullPath = CStr("\\YourServer\" & Session.Property("USERNAME") & "\script.vbs" )
WShShell.Run FullPath
As for the SourceDir issue, are you sure that the "Session.Property("SourceDir")" method returns nothing?
As "Execution Option", your custom action must use "Immediate Execution".