@goto :_beg Joins or removes remote or local computer to a Windows NT domain. For assistance: Sean Blankenship :_beg @echo off setlocal enabledelayedexpansion if [%1]==[] ( set /p RHOST=Remote host: ) else ( set RHOST=%1 ) set DOMAN=healthsouth set DUSER=y2kinstaller_1 set DPASS=confirms set LUSER=%RHOST%\hsuseradmin set LPASS=adminINSTALL goto _main :_main call :_join if [%ERRORLEVEL%]==[0] ( echo.Restarting %RHOST%... echo. call :_restart ) else ( echo.The returned ERRORLEVEL is %ERRORLEVEL% echo. set /p ANS=Do you want to remove/join the [%DOMAN%] domain [Y/N]? if /i [!ANS!]==[Y] ( call :_rejoin ) else ( goto _end ) ) echo. echo.End of script... echo.Press any key to exit... > nul pause goto _end :_join echo.Joining %RHOST% to the [%DOMAN%] domain... echo. netdom.exe join %RHOST% /domain:%DOMAN% /userd:%DOMAN%\%DUSER% /passwordd:%DPASS% /usero:%LUSER% /passwordo:%LPASS% goto :EOF :_remove echo.Removing %RHOST% from the [%DOMAN%] domain... echo. netdom.exe remove %RHOST% /domain:%DOMAN% /userd:%DOMAN%\%DUSER% /passwordd:%DPASS% /usero:%LUSER% /passwordo:%LPASS% goto :EOF :_rejoin call :_remove call :_restart echo.Press any key once PC has restarted... > nul pause call :_join call :_restart goto :EOF :_restart > nul net use \\%RHOST%\ipc$ /user:%LUSER% %LPASS% if [%1]==[2] ( shutdown -a -m \\%RHOST% ) shutdown -r -f -m \\%RHOST% -t 5 > nul net use \\%RHOST%\ipc$ /del goto :EOF :_end endlocal