@echo off
net user %username% | find /i "administrators" >nul 2>nul
if %errorlevel%==1 (echo 普通用户)else echo 管理员
pause
使用else ,不必用goto。也可以使用&&和||来替换if的判断
[ Last edited by Hanyeguxing on 2009-12-19 at 00:47 ]作者: everest79 时间: 2009-12-21 03:55 wmic process where name='csrss.exe' getowner
wmic process where name='cmd.exe' getowner作者: bootp 时间: 2009-12-21 04:56 非常感谢!!5楼代码有效。
请教7楼,代码没看明白,能稍加解释吗?作者: everest79 时间: 2009-12-22 04:31 wmic process where name='cmd.exe' getowner
查看进程cmd.exe的所有者,也就是运行用户名,你以超级用户执行或当前登录用户执行cmd.exe,使用这个查询可以看到不同的用户名
例如
wmic process where name='csrss.exe' getowner
的所有者是system作者: yishanju 时间: 2009-12-22 05:37 7楼才是正解。作者: bootp 时间: 2009-12-22 18:36 非常感谢!!
各自运行了一下,这个代码可以判断出某进程的所有者。
上面给出的答案可以判断出当前用户是不是管理员。