Script to call file from dynamic path

Home Forums Scripting General Scripting Script to call file from dynamic path

Viewing 1 post (of 1 total)
  • Author
  • Avatar

    Rems has been helping me behind the scene and I wanted to post his work as I think it might help others. Also, this will allow others to chime in with additional ideas.

    My question. How does one create a script to call a file (exe or msi) from a dynamic path. For example, I will be pushing out an application via sms. The sms package will consist of a folder containing 1 script and 1 msi. The problem is that the location of the package may differ therefore a static path such as (c:windowssms) will not suffice as the folder may exist in random locations.

    Rems provide the below information. I have not yet tested it. I will report back later today with my results.

    Rems says: this example below and the links might get you started;


    strPath = Wscript.ScriptFullName
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)
    Set objFile = objFSO.GetFile(strPath)

    strFolder = objFSO.GetParentFolderName(objFile) & “”
    strExeFile = “file.exe /parameters”

    strCommand = chr(34) & strFolder & strExeFile & chr(34)

    Set objShell = CreateObject(“Wscript.Shell”)
    objShell.Run “%comspec% /c ” & strCommand, 1, False

    Please feel free to add comments or alternate suggestions.
    I want to thank Rems again for coming through with a solution. I am actually learning a lot from this help. Hopefully I will be able to return the favor at some point. Cheers.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.