我有一个VBScript可以将Internet Explorer设置为默认浏览器。我想使用PowerShell远程执行该VBScript。我尝试了以下命令:
$result = Invoke-Command -ComputerName $computerName -ScriptBlock {
Invoke-Expression -Command:"cmd.exe /c cscript.exe
C:\Users\mani\Desktop\test.vbs"
} -Credential $MySecureCreds
我也尝试了以下方法:
$result = Invoke-Command -ComputerName $computerName -ScriptBlock {
cscript.exe C:\Users\mani\Desktop\test.vbs"
} -Credential $MySecureCreds
test.vbs 代码如下:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\system32\control.exe /name Microsoft.DefaultPrograms
/page pageDefaultProgram\pageAdvancedSettings?pszAppName=Internet%20Explorer"
WScript.Sleep 1200
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys " "
WshShell.Popup " Internet Explorer set as Default Browser Successfully!!!. ", 3, "Default Browser"
WScript.Quit
但是,通过使用以上命令,默认浏览器没有更改。如果我手动运行VBScript,虽然可以。如何远程执行VBScript?