Run PowerShell script from folder Program Files via VBScript -


how can run powershell script within %programfiles% folder?

i have tried variable %programfiles% without progress, "program files" can't ut work.

my current code

set shell = wscript.createobject("wscript.shell") shell.run("powershell c:\program files\temp\test.ps1"), 0 , true 

it's working if use network share without spaces

set shell = wscript.createobject("wscript.shell") shell.run("powershell \\domain\sysvol\script\test.ps1"), 0 , true 

i have tried using """ can't powershell work.

anyone know how solve this? need use vbscript in order start powershell script in background @ logon via gpo. otherwise show powershell window.

try this. add parameter "-file" , double quotes around path. can , store %programfiles% in variable using expandenvironmentstrings:

set shell = wscript.createobject("wscript.shell")  sprogramfiles = shell.expandenvironmentstrings("%programfiles%")  shell.run "powershell -file """ & sprogramfiles & "\temp\test.ps1""", 0 , true 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -