Running an exe file with parameters in a VBScript

后端 未结 2 694
说谎
说谎 2021-01-24 17:15

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

2条回答
  •  旧时难觅i
    2021-01-24 17:54

    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
      

提交回复
热议问题