Windows Command Line Cheat Sheet


Change Drive from Command Line

You are here: D:\
You want to go here: C:\

Type just:

C:

and hit enter.

You are here: C:\Windows\System32\drivers\
You want to go here: C:\

Type:

C:\

and hit enter. Notice you have to type the back slash in this case.


Running Commands

Run a command whose path has spaces in it:
You have to wrap the entire command, but NOT the arguments, in quotes, for example:

C:\Users\yourusername\.gradle>"C:\Program Files (x86)\Java\jdk1.8.0_172\bin\keytool.exe" -importcert -file ca.crt -keystore gradle.jks -alias yourdomain.com

Web Development

Edit your hosts file in Windows 7
As admin user, type:

notepad C:\Windows\System32\drivers\etc\hosts

Add localhost domain to ACL
As admin user, type:

netsh http add urlacl url=http://localhost.mydomain.com:8080/ user=everyone

Open Developer Tools in Edge on Windows 10.
As of Nov 2018, just hitting F12 or clicking on “Developer Tools” in the “…” menu doesn’t work anymore. You first need to open a PowerShell window and run this command below, and then hit F12 or click on “Developer Tools” in the “…” menu. Why oh why??

Add-AppxPackage -register "C:\windows\SystemApps\Microsoft.MicrosoftEdgeDevToolsClient_8wekyb3d8bbwe\AppxManifest.xml" -DisableDevelopmentMode -Confirm:$false

Flush DNS cache

As admin user, type:

 ipconfig /flushdns

and hit Enter.


Run As Admin

From cmd shell:

runas /user:DOMAIN\USERNAME cmd.exe

This will open a new terminal window from where you can run an app as admin.

Or, right click on the Command Prompt app icon, and choose “Run as administrator”


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.