首页 > 其他 > 详细

批处理更改工作组为Administrator

时间:2014-08-11 00:29:41      阅读:419      评论:0      收藏:0      [点我收藏+]

@echo off

:: 检测命令行参数1
if not %1#==# set JoinWorkgroup=%1
if not %Joinworkgroup%#==# goto _doit

:: 从当前目录下的sysprep.inf中获得
if not exist sysprep.inf goto _noGrpName
for /f "usebackq tokens=*" %%i in (`type sysprep.inf ^| find /i "JoinWorkgroup"`) do @set %%i

:: 如果以上都没有,默认设置为BDGROUP
:_noGrpName
if %JoinWorkgroup%#==# set JoinWorkgroup=administrators

:_doit
:: 先检查当前工作组设置,如果相同,则不修改
wmic computersystem get domain | findstr /r /i "^%JoinWorkGroup%$" > nul
if %errorlevel%==0 goto _quit
:: 检查环境变量COMPUTERNAME是否为空,如果为空,则从WMI数据库中提取
if not %COMPUTERNAME%#==# goto _change
for /f "usebackq skip=1 tokens=*" %%i in (`wmic computersystem get name`) do set CNAME=%%i
if %CNAME%#==# goto _quit
set COMPUTERNAME=%CNAME%

:_change
echo Changing Workgroup to "%JoinWorkgroup%" ...
echo.
wmic computersystem where Name="%COMPUTERNAME%" call JoinDomainOrWorkgroup Name="%JoinWorkgroup%"
if %errorlevel%==0 goto _success
goto _quit

:_success
echo Successfully Changed Workgroup to "%JoinWorkgroup%".
echo.

:_quit
for %%i in (Joinworkgroup cname) do set %%i=

批处理更改工作组为Administrator,布布扣,bubuko.com

批处理更改工作组为Administrator

原文:http://blog.csdn.net/cxx504659987/article/details/38474789

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!