Benjamin Jones
Benjamin Jones

Reputation: 997

Run .vbs within subfolder

Right now if I run a VBScript from a VBScript like this:

CreateObject("Wscript.Shell").Run("""runscript.vbs""")

This opens up runscript.vbs, which works!

If a create a subfolder to put the VBScript and reference it like below:

CreateObject("Wscript.Shell").Run("""x64/runscript.vbs""")

No error, but the script doesn't open like it should.

I know absolute path would work, but for the purpose of the script I can't use absolute path.

Upvotes: 1

Views: 889

Answers (1)

Bond
Bond

Reputation: 16311

Either of the following should work.

  1. Use a backslash instead of a forward slash:

    CreateObject("WScript.Shell").Run "x64\runscript.vbs"
    
  2. Use the CurrentDirectory property to set the working folder:

    With CreateObject("WScript.Shell")
        .CurrentDirectory = "x64"
        .Run "runscript.vbs"
    End With
    

Upvotes: 3

Related Questions