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
Post a Comment