Old script I wrote up one day while thinking about how to best randomly annoy an admin. I never finished the full plan for this, maybe someday. Anyways what it does is dumps a list of the current computers from net view, parses it out. It generates a random number with the %random% variable 2 times, then checks how many items are in the list generated by net view + parsing and checks if the poorbastard variable is less than the number of items in the list, if not it removes the first number from the poorbastard variable then rechecks until it's less or equal to the items in the list. Then issues a remote shutdown command to that computer. Obviously you need admin rights on the remote computer for this to function.
-=The Script=-
@echo off
if exist C:\list2.txt del /f /q C:\list2.txt
net view >> C:\list.txt
for /F "skip=3 tokens=1" %%c IN (C:\list.txt) DO echo %%c >> c:\parsed0.txt
for /f %%G in (C:\parsed0.txt) do if NOT %%G==The echo %%G >> C:\parsed1.txt
for /F "delims=\\ tokens=1" %%g IN (C:\parsed1.txt) DO echo %%g >> C:\list2.txt
del /f /q C:\parsed0.txt > nul
del /f /q C:\parsed1.txt > nul
del /f /q C:\list.txt
for /f %%f in ('find /v /c ^"The command completed successfully.^" ^< C:\list2.txt') do set /a V=%%f
set /a poorbastard=%random%+%random%
echo %poorbastard%
if %poorbastard% LEQ %v% goto kill
if %poorbastard% GTR %v% goto minus50dkp
:minus50dkp
set poorbastard=%poorbastard:~1%
if %poorbastard% LEQ %v% goto kill
if %poorbastard% GTR %v% goto minus50dkp
:kill
setlocal ENABLEDELAYEDEXPANSION
set /a n=1
for /f %%a in (C:\list2.txt) do (
if /I !n! equ %poorbastard% set saygoodnight=%%a
set /a n=!n! + 1
)
echo %poorbastard%
echo %saygoodnight%
shutdown -r -m \\%saygoodnight% -t 00 -c "LEEEEEEEEEEROOOOOOOOY jenkins!!!!!!"
set %saygoodnight%=
set %poorbastard%=
set %v%=
pause
No comments:
Post a Comment
All comments moderated.
Comments like "sweet dude" or "this is awesome" or "thanks" will be denied,
if you've got something genuinely interesting to say, say it. Other than that just sit back and bask in the glory.