我正在尝试通过 PowerShell 登录命令使用 Windows Sandbox。这是LogonCommand
我的 WSB 文件的部分:
<LogonCommand>
<Command>C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -executionpolicy unrestricted -file "C:\\Users\\WDAGUtilityAccount\\Desktop\\boot.ps1" -noexit</Command>
</LogonCommand>
Windows Sandbox 实例加载正常,表明 WSB 文件内容没有语法/验证问题,但未显示 PowerShell 窗口。添加-windowstyle normal
没有影响。
我怀疑LogonCommand
内容在命令提示符中运行,该命令提示符不可见,因此运行命令以从中打开 PowerShell 以某种方式“继承”不可见的终端窗口。
在这种情况下是否可以强制 PowerShell 终端窗口显示出来?我想这样做,以便我可以看到由于 PowerShell 脚本未按预期执行并且我对任何输出/进度指示视而不见而收到的错误。
Found an答案(看起来不是最干净的选项,但有效):
<Command>powershell -executionpolicy unrestricted -command "start powershell {-noexit -file C:\Users\WDAGUtilityAccount\Desktop\boot.ps1}"</Command>
-
powershell
switches from CMD to PowerShell
-
-windowstyle normal
无法使该 PowerShell 窗口可见
-
-executionpolicy unrestricted
允许嵌套的 PowerShell 从文件运行
-
start powershell
runs another PowerShell with visible window
- 直接运行这个
LogonCommand
不管用
-
-noexit
tells the nested PowerShell to remain visible
-
-file C:\Users\WDAGUtilityAccount\Desktop\boot.ps1
runs the given script
- 通过使用与机器共享
MappedFolder
在 WSB 配置中
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)