If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.
change logon /disable
for /f "tokens=1,2,3,4,5 skip=3" %%f in ('quser') do if %%f==%username% (echo .) else (logoff %%h)
waitfor /t 120 MYJAVASIGNAL
change user /install
c:\temp\java\java.exe /s
change user /enable
shutdown /r /t 0
change logon /disable
for /f "tokens=1,2,3,4,5 skip=3" %%f in ('quser') do if %%f==%username% (echo .) else (logoff %%h)
waitfor /t 120 MYJAVASIGNAL
for /f "tokens=1,2,3,4,5 skip=3" %%f in ('quser') do if %%f==%username% (echo .) else (reset %%g)
waitfor /t 120 MYJAVASIGNAL
change user /install
c:\temp\java\java.exe /s
change user /enable
shutdown /r /t 0
@echo on
@CLS
cd\
for /f "tokens=3" %%a in ('QWinSta ^| find /i "rdp" ^| find /v ">rdp"') do (if %%a LSS 65536 logoff.exe %%a)
for /f "tokens=2" %%i in ('QWinSta ^| Find /i "Disc"') Do logoff.exe %%i
change logon /disable
for /f "tokens=3 skip=3" %%f in ('quser ^| findstr /i "disc"'') do logoff %%f
waitfor /t 120 MYJAVASIGNAL
for /f "tokens=3 skip=3" %%f in ('quser') do if %%f==%username% (echo .) else (logoff %%h)
waitfor /t 120 MYJAVASIGNAL
for /f "tokens=3 skip=3" %%f in ('quser') do if %%f==%username% (echo .) else (reset %%g)
change user /install
c:\temp\java\java.exe /s
change user /enable
shutdown /r /t 0
My concern with the script you used however -- It doesn't take into account a few possible factors:1. If you have ICA sessions - I know you didn't mention Citrix, but I always try to assume it's a possibility.1. Not using Citrix
2. If you run it from an RDP session.. you will potentially screw yourself with that one since it is logging off all of the RDP sessions.2. I am not screwing myself, because actually the session running this script has an < in front of it, thereby not being logged off Cool eh :)
3. It also does not take into account any sessions that refuse to logoff & get hung in the process.
4. It does not take into account a session that goes into a down state.. (this used to be a huge problem).4. Never seen those fortunatly.
5. It does not wait to be sure the sessions logout -- if you start your install instantly after the logoffs, then there is a chance your java install may have issues.5. Ah yes, the script is much longer than posted here. I have some more checks.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.