我有一个带有界面的批处理文件。单击添加或删除用户时,我希望能够执行Powershell文件。当我使用此代码运行.bat文件时,它给我错误“ Powershell未定义。对我来说一切正常。有什么建议吗?
<!-- :: Batch section
@echo off
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPathAdd =%ThisScriptsDirectory%powershelladd.ps1
SET PowerShellScriptPathRemove =%ThisScriptsDirectory%powershellremove.ps1
echo Select an option:
for /F "delims=" %%a in ('mshta.exe "%~F0"') do set "HTAreply=%%a"
echo End of HTA window, reply: "%HTAreply%"
goto :EOF
-->
<HTML>
<HEAD>
<HTA:APPLICATION SCROLL="no" SYSMENU="no" >
<TITLE>HTA Buttons</TITLE>
<SCRIPT language="JavaScript">
window.resizeTo(374,100);
function closeHTA(reply){
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.GetStandardStream(1).WriteLine(reply);
window.close();
}
</SCRIPT>
</HEAD>
<BODY>
<button onclick=PowerShell -NoProfile -ExecutionPolicy Bypass -Command "&
'%PowerShellScriptPathAdd%'";>Add User</button>
<button onclick=PowerShell -NoProfile -ExecutionPolicy Bypass -Command "&
'%PowerShellScriptPathRemove%'";>Add User</button>
<button onclick="closeHTA(3);">Exit</button>
</BODY>
</HTML