我想从bat文件启动RunAs脚本的PowerShell脚本。这工作。从bat文件启动powershell时出现语法错误
@echo
SET "InstallerFolder=\\dc01\e\script"
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%InstallerFolder%\Script.ps1""' -Verb RunAs}";
但是,如果我补充一下:
-RedirectStandardOutput ""%InstallerFolder%\node.txt""
它打破。
所以行看起来是这样的:
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-RedirectStandardOutput ""%InstallerFolder%\node.txt"" -NoProfile -ExecutionPolicy Bypass -File ""%InstallerFolder%\TSM Client Install Script.ps1""' -Verb RunAs}";
以及其中如此之快,我不能看到它的PowerShell的错误resuslts。 可能的语法?
非常感谢! 谢谢。
将'-NoExit'参数添加到Powershell,所以它不会退出,您可以阅读错误消息。 – vonPryz 2014-11-05 09:40:27
去哪里?当我这样做时出现错误: 找不到与参数名称'noexit'匹配的参数。 – user3019059 2014-11-05 09:47:50
由于您没有告诉您尝试添加开关的位置,请阅读Powershell.exe的[help](http://technet.microsoft.com/zh-cn/library/hh847736.aspx),然后查找正确的语法。 – vonPryz 2014-11-05 11:31:41