Personal list of useful Windows commands.
TechNet: Command-line reference A-ZSimple Commands
Text Files
start textfile.txt
(Opens text file in editor)
start notepad++ textfile.txt
(Opens text file in Notepad++)
find "search
(Find all instances of search string in text file)
string" textfile.txt
find /n "search
(Find all instances of search string in all text files, with line numbers)
string" *.txt
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 >
(Print all TCP ports and executables to text file)
temp_ip.txt
netstat -a -p TCP | grep
(Find all TCP ports starting with 22)
:22
reg query
(Find Proxy)
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | find /i "proxyserver"
Services
General
sc query | findstr name_to_search_for | findstr
(get SERVICE_NAME of service(s))
SERVICE_NAME
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|
(Find and sort all environment variables containing search_term)
sort
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
(Remove global variable)
VARIABLE_NAME
setx VARIABLE "Value"
(Set permanent current user variable)
REG DELETE "HKCU\Environment" /f /v VARIABLE_NAME
(Remove user variable)
PowerShell
Get-ChildItem Downloads -name
Other
whoami /groups > c:\my_groups.txt
(List user groups to which the current user belongs)
top