Rossi
Rossi

Reputation: 23

vbs run ps1 from any location

I'm trying to run ps1 script via VBS but it is only working for me when full path of PS1 is given. c:\scripts\test.ps1

works with full path Set objShell = CreateObject("Wscript.Shell") objShell.Run("powershell.exe -noexit c:\scripts\test.ps1") But I need that I can move script to different locations there for fixed path is not gonna work for me.

I have tried placing PS1 in to same folder where vbs is bit still can't make it work

Not working as objShell.Run("powershell.exe -noexit test.ps1") nor objShell.Run("powershell.exe -noexit .\test.ps1")

Any help appriciated.

Upvotes: 1

Views: 1388

Answers (1)

Kris Powell
Kris Powell

Reputation: 131

Try doing the following to reference the local directory of the script.

Set objShell = CreateObject("Wscript.Shell")
objShell.Run("powershell.exe -noexit .\test.ps1")

Upvotes: 0

Related Questions