To show the current running processes
NET SART/NET STOP
To start or stop services
FINDSTR /M /S "searchstring" *.*
Find a string from the files specified by the file pattern
SET LofFilePath=C:\Test%date:~-4,4%%date:~-10,2%%date:~-7,2%.log
Use this to create a logfile path with date stamp
%~d0
CD "%~d0%~p0"
Use this to set the default folder to the location of batch script
SC query
A util to check status of Windows services
NET localgroup GroupName
Get a list of user accounts assigned into this localgroup
LOGEVENT -s S|T|W|E|F -c 0 -e -1 -r "SourceName" "BodyText"
EVENTCREATE /S ServerName /L Application /T ERROR /SO "SourceName" /ID 1 /D "BodyText"
EVENTCREATE /S ServerName /L Application /T ERROR /SO "SourceName" /ID 1 /D "BodyText"
Use this to create an entry in the EventLog
FOR /d /r . %%d in (bin.) do @if exist "%%d" rd /s/q "%%d"
Remove all file folders with the specified name "bin."
FORFILES /P "C:\Archive" /M *.* /D -30 /C "CMD /c DEL /q @path"
Remove files from the folder "C:\Archive" that are 30 days or older
QWINSTA /SERVER:RemoteServer
QUERY USER
Display all connected (active or inactive) users
LOGOFF sessionID /SERVER:RemoteServer
Force a user account to logoff
ECHO %date:~-4,4%-%date:~-10,2%-%date:~-7,2%
Format the date
for %i in (notepad.exe) do @echo %~$PATH:i
Search for the first folder exe is being executed from
Remove all file folders with the specified name "bin."
FORFILES /P "C:\Archive" /M *.* /D -30 /C "CMD /c DEL /q @path"
Remove files from the folder "C:\Archive" that are 30 days or older
QWINSTA /SERVER:RemoteServer
Find out all the existing sessions from a remote server
RWINSTA 2
/SERVER:RemoteServer
Close
a remote seesion by IDQUERY USER
Display all connected (active or inactive) users
LOGOFF sessionID /SERVER:RemoteServer
Force a user account to logoff
ECHO %date:~-4,4%-%date:~-10,2%-%date:~-7,2%
Format the date
for %i in (notepad.exe) do @echo %~$PATH:i
Search for the first folder exe is being executed from
for /F %i in ('findstr /M "SynnexB2B" *.dat') DO
DEL %i
Delete found files
quser
User this comment to query who is login on a server. Below is a script to list all users:
FOR /F "tokens=1-6" %%i IN ('quser /SERVER:MyServer') DO (
IF "%%i" NEQ "USERNAME" (
IF "%%k" EQU "Disc" (
ECHO Svr=MyServer UName=%%i ID=%%j %%k Since=%%m
) ELSE (
ECHO Svr=MyServer UName=%%i ID=%%k %%l Since=%%n
)
)
)
quser
User this comment to query who is login on a server. Below is a script to list all users:
FOR /F "tokens=1-6" %%i IN ('quser /SERVER:MyServer') DO (
IF "%%i" NEQ "USERNAME" (
IF "%%k" EQU "Disc" (
ECHO Svr=MyServer UName=%%i ID=%%j %%k Since=%%m
) ELSE (
ECHO Svr=MyServer UName=%%i ID=%%k %%l Since=%%n
)
)
)
netstat -an 2 | findstr "15.200.14 15.201.8
15.217.72"
Tracking incoming HTTP Posting
No comments:
Post a Comment