如何使用这两个代码杀死同一用户的多个任务?
代码no1
@ECHO OFF
TASKKILL /F /IM explorer.exe
cls
Echo "Please Specify the User ID"
Set /p u=
set USER=%u%@%userdomain%
Echo "Please Specify the PASSWORD"
runas /user:%USER% Explorer.exe
cls
echo "Press any key to Switch Back to Default USer Profile"
Pause
Echo "please enter your password again for verification"
runas /user:%USER% C:\switch.bat
pause
cls
start %windir%\explorer.exe
exit代码no2 (此文件名为Switch.bat)
@echo off
TASKKILL /F /IM Explorer.exe
exit实际上,创建它的总体思路是在不注销的情况下切换到win XP,如win 7
问题是,当它切换回原始配置文件时,第二个用户的所有任务都不会停止
是否有办法停止正在运行特定用户的所有任务
发布于 2013-07-21 04:35:38
您可以尝试使用tskill。它可以终止一个进程,并接受用户ID作为参数:
删除同一用户的资源管理器
setlocal enabledelayedexpansion
set exe_name=Explorer
for /f "skip=1 tokens=1,2,3" %%S in ('query user') do (
set "current_user=%%S"
if "!current_user:~0,1!" EQU ">" (
for /f "tokens=2 delims= " %%M in ('tasklist ^| find ^"%exe_name%^"') do (
tskill "%%M" /ID:%%U
)
)
)
endlocal
goto :eof对于所有其他用户:
setlocal enabledelayedexpansion
set exe_name=Explorer
for /f "skip=1 tokens=1,2,3" %%S in ('query user') do (
set "current_user=%%S"
if "!current_user:~0,1!" NEQ ">" (
for /f "tokens=2 delims= " %%M in ('tasklist ^| find ^"%exe_name%^"') do (
tskill "%%M" /ID:%%U
)
)
)
endlocal
goto :eofhttps://stackoverflow.com/questions/17766291
复制相似问题