ITandME blog

January 21, 2015: Windows CLI commands and scriptables

A list of Windows commands I use all the time to get away from the GUI

cmd.exe // command terminal mstsc.exe // remote desktop console lusrmgr.msc // local user manager telnet.exe important note, Telnet DOES NOT SCRIPT!* SCRIPTABLES... :: Remote access to another server's terminal console psexec \\remoteIP -u (domain/username) -p (password) -s cmd.exe :: Find processor architecture...among other info systeminfo | findstr /I type: :: Timeouts...for those processes that could raise alarms... TIMEOUT /T (seconds) :: FOR Loop FOR /f "tokens=1,2*" %%N IN (file.txt) DO () :: Uninstall application via UID (no interaction) msiexec.exe /x {02A21E03-807D-4B7E-BA68-4FEEBFFEAAE4} /quiet :: Install application via .msi (no interaction msiexec.exe /i application.msi /quiet :: Echo the month ECHO %DATE:~-10,2% :: Rename file REN" "" :: Make a new folder mkdir dirname :: IF statements: GEQ = Greater/Equal to; LSS l= less than; :: Delete files older than n days... forfiles /p "/path" /s /m *.* /c "cmd /c Del @path" /d -n :: Find System Architecture: echo "%PROCESSOR_ARCHITECTURE%" :: Partially automate a RDP sessions for a list of servers for /f %%A in (list.txt) do (mstsc /v:%%A) :: Echo day: echo "%DATE:~-7,2%" (may vary depending on OS version) :: Echo month echo "%DATE:~-10,2%" (may vary depending on OS version) :: Enable default Administrator account net user administrator /active:yes :: Renaming Duplicate files DIR /b C:\folder\ >> newlist.txt FOR /F %%A IN (newlist.txt) DO ( IF EXIST ".\folder\%%A" (ECHO rename %%A) REN .\folder\%%A "%DATE:~-10,2%-%%A" MOVE .\another folder\%%A .\folder\ ) DEL newlist.txt :: Activate Windows Offline... slmgr -ipk slui 4 # go through phone registration...dial 1 for yes, 2 for no...