我有一个简单的PowerShell脚本来停止进程:
$p = get-process $args
if ( $p -ne $null )
{
$p | stop-process
$p | select ProcessName, ID, HasExited, CPU, Handles
}
else { "No such process" }
Run Code Online (Sandbox Code Playgroud)
如果我尝试停止当前用户未启动的进程; 它适用于Windows Server 2003.但是,在Windows Server 2008(和其他带有用户帐户控制的Windows风格)上,我收到以下错误:
Stop-Process : Cannot stop process "w3wp (5312)" because of the following error: Access is denied
Run Code Online (Sandbox Code Playgroud)
有没有办法解决这个问题,而无需使用提升权限运行PowerShell?如果用户在尝试执行需要提升的操作时,只是出现了UAC提示,那就没问题.