CommandPad

Personal list of useful Windows commands.

TechNet: Command-line reference A-Z

Simple Commands

Text Files
start textfile.txt (Opens text file in editor)
start notepad++ textfile.txt (Opens text file in Notepad++)
find "search string" textfile.txt (Finds all instances of search string in text file)
find /n "search string" *.txt (Finds all instances of search string in all text files, with line numbers)

Networking

General
nslookup servername (Get DNS information)
ping servername -n 5 (Ping address x times)
ipconfig /dnsflush (Purges the DNS Resolver cache)
ipconfig /renew (Renew the IPv4 address for the specified adapter)
netstat -a -b (List ports and executables)
netstat -a -b -p TCP > temp_ip.txt (Print all TCP ports and executables to text file)
netstat -a -p TCP | grep :22 (Find all TCP ports starting with 22)
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | find /i "proxyserver" (Find Proxy)

Services

General
sc query | findstr name_to_search_for | findstr SERVICE_NAME (get SERVICE_NAME of service(s))
sc queryex exact_service_name (extended status of service)
sc qc exact_service_name (configuration information of service)
sc stop "SERVICE_NAME"
sc start "SERVICE_NAME"
sc config "SERVICE_NAME" obj= Account password= Password
C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe /f C:\path\to\the\service.exe

File System

Files
dir /b > c:\filelist.txt (directory contents to text file)

Environment Variables

set (List all environment variable)
set | grep search_term| sort (Find and sort all environment variables containing search_term)
echo %PATH% (Access value of single variable)

TechNet: Using Setx
setx VARIABLE "Value" /m (Set permanent global variable)
REG DELETE "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /f /v VARIABLE_NAME (Remove global variable)
setx VARIABLE "Value" (Set permanent current user variable)
REG DELETE "HKCU\Environment" /f /v VARIABLE_NAME (Remove user variable)

Other

whoami /groups > c:\my_groups.txt (List user groups to which the current user belongs)
top

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: