I need to create a script that runs setup.exe /configure Install.xml from the folder the script is located.
When I run the script below, it does find the
Thanks guys! I mixed it up and made this that works for me. (Not sure if something could be made cleaner, but it works!)
Dim WshShell
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set objShell = CreateObject("Wscript.Shell")
Set WshEnv = WshShell.Environment("PROCESS")
Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
objShell.CurrentDirectory = strFolder
WshEnv("SEE_MASK_NOZONECHECKS") = 1
WshShell.Run("setup.exe /Configure Install.xml"), 0, true
WshEnv.Remove("SEE_MASK_NOZONECHECKS")
wscript.quit(RetVal)
Most likely your code doesn't find and run the setup.exe in the script folder, but a different setup.exe somewhere in the %PATH%.
Simply appending the folder to the commandline is not going to do what you want. There are two ways for you to solve this issue:
Run setup.exe with the full path, as suggested by @AlexK.. You probably need to provide the full path to Install.xml too. Use the BuildPath method for constructing the paths. You may also want to add quotes around the paths to take care of spaces in them.
Function qq(str) : qq = """" & str & """" : End Function
strPath = qq(objFSO.BuildPath(strFolder, "setup.exe")) & " /configure " & _
qq(objFSO.BuildPath(strFolder, "Install.xml"))
objShell.Run strPath
Change the working directory to the folder containing your script and setup.exe and run the command without path (or the relative path .\setup.exe).
objShell.CurrentDirectory = strFolder
strPath = "setup.exe /configure Install.xml"
objShell.Run strPath