Running an exe file with parameters in a VBScript

后端 未结 2 720
说谎
说谎 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条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-24 17:46

    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)
    

提交回复
热议问题