windows - 如何使用 PowerShell 远程执行 VBScript?
问题描述
我有一个 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?
解决方案
推荐阅读
- node.js - 出现错误:无法将请求 /api/plaid/accounts 从 localhost:3000 代理到 http://localhost:5000/
- python-3.x - AttributeError: 'list' object has no attribute 'shape' ,我该如何修复这种类型的错误?
- java - 从函数中调用控制器方法
- javascript - 在一个窗口中循环不同的 URL
- python - Python - 如何合并和交换两个列表的每个第 n 个元素
- python - 每次运行程序时自动更改文件名
- php - 如何在 Laravel Eloquent 中应用分页和偏移
- typescript - 如何使用 ngFor 创建一个只有唯一结果的选择框
- r - 当两个输入相互更新时如何避免无限循环?
- apache-spark - java spark withColumn绑定属性错误