Episode: 1904
Title: HPR1904: Windows Command Line Tips and Tricks
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr1904/hpr1904.mp3
Transcribed: 2025-10-18 11:00:32

---

This is HPR Episode 1904 entitled, Windows Command Line Tips and Tricks.
It is posted by first time, though only half the time, and is about seven minutes long.
The summary is, some tips to make you feel more comfortable on the Windows Line on things.
This episode of HPR is brought to you by An Honesthost.com.
Get 15% discount on all shared hosting with the offer code, HPR15, that's HPR15.
Better web hosting that's honest and fair, at An Honesthost.com.
Howdy Hacker Public Radio. I am only half the time, the reluctant Windows admin.
I'm a Linux user at home and at heart. I run VPSs on digital ocean host websites all in Linux, mostly Ubuntu.
By day, however, I work for a managed services provider, which deals with all Windows boxes.
Today I'd like to talk about some tips and tricks I've come across while being forced to make the best out of a Windows environment.
Being a Linux user, I find that many functions are more quickly completed if you drop to a command line interface.
This holds true for many Windows functions as well.
First, let's establish the kind of environment you'll need.
Unfortunately, there is no pseudo command built into Windows.
What we will need to do is run a command prompt as an administrator.
On Windows 7, you can accomplish this by clicking on the start menu, typing cmd, that's Charlie, Mike, Delta.
Then right-clicking on the command prompt program and choosing run as administrator.
In Windows 8 and 10, you can right-click the start menu directly and click command prompt, Perenn's admin.
This is almost the equivalent to running as root.
You can affect almost everything except some protected system files. No RMTAC RF slash star for you.
The Windows user most like root would be system.
Running a command prompt as system is possible to accomplish a few ways, but is very rarely needed.
I can make another podcast about that later, but it is out of scope here.
Let's get into our first example.
User creation is so much easier at the Windows command line, for example.
I want to add a local user, John, to a system with administrative rights.
From an admin command prompt iType, net, space, user, space, John, space, hunter2, space, forward slash add.
This creates the user, John, with the password hunter2, then iType, net, space, local group, space, administrators, space,
John, space, forward slash add.
This adds John to the local group, administrators. This group has admin rights on this local machine.
Say John abuses this privilege and needs to have his permissions provoked.
Net, space, local group, space, administrators, space, John, space, slash delete.
This is much easier than going to the control panel.
Searching for users, adding a user, defining a password, choosing it to make it an admin user, etc.
For me at least.
Another thing the net command is used for is restarting services.
Does that sound silly to you?
I agree.
Regardless, let's say you want to restart the principal or on a troubled workstation.
You could open a run prompt by hitting Windows key R, typing services.msc.
This opens up the services window where you can find the service print spoiler and right click at the restart.
Or you could just type net, stop, spooler, net, start, spooler.
This is easier to script as well.
In case the user is always having trouble printing.
Provide a simple batch file, the equivalent of a shell script, to resolve and get on with your day.
Effecting files can be a pain in Windows as the paths tend to be esoteric and alien to a Linux user.
For example, let's say I want to copy the file through .bar in the open VPN programs folder to my desktop.
Now, don't bother following along for this next bit because it is really big and I'm just going to run through it quickly.
I could type.
Copy, double quotes.
C, colon, backslash, program, space, files, space, open parenz, x86, close parenz, backslash, open VPN, space, technologies.
Backslash, open VPN, space, client, backslash, etc, backslash, profile, backslash, food.bar.
Close quotes, space, double quotes.
C, colon, backslash, users, backslash, john, backslash, desktop, backslash, food.bar.
Close quotes.
Better remember those double quotes since Windows has spaces and parentheses in the full path.
Wow, even with tab completion, that's a lot of work.
I have a better solution if you have access to the graphical user interface.
If you open up an explorer window, find the file which you wish to copy and drag it into the command window.
Windows will enter the full path into the prompt.
If the file does not already exist where you want it, you can't drag it to the prompt.
There are variables that can speed up this process.
It may not be as elegant and as simple as tilde, but Windows does have a variable for the local user's home directory.
You can type percent that's shift 5 on a usc board.
Percent home path that's Hector, Oscar, Mike, Echo, Papa, Alpha, Tango, Hotel, followed by another percent.
Slash desktop, slash, food.bar.
But you're saying wait only half the time.
This doesn't save me any time or keystrokes.
That is true in this specific case, but in scripting, it becomes important to use variables instead of full paths.
I may not have Windows installed in the C drive, for example.
Also some real time savers, if you use percent app data percent, it maps to C colon, backslash, users, backslash, user name, backslash, app data, backslash roaming.
Now, let's say I'm going to be doing a lot of work in a specific directory.
I could keep entering the full path, but come on, no one likes that guy.
I could open a command prompt in CD or change directory just like in Linux.
Or, I could find the directory in File Explorer that I want.
Right click inside the folder while holding down the Shift key, which gives you an extra option in the context menu.
Named OpenCommandWindowsHere, which does exactly that.
You'll get a command window opened with the working directory set as the folder in which you right-click.
Hopefully, some of these methods will help folks like me.
Windows Admin by day, Linux enthusiast by night.
This is only half the time the reluctant Windows Admin signing off.
You've been listening to heckaPublicRadio at heckaPublicRadio.org.
We are a community podcast network that releases shows every weekday, Monday through Friday.
Today's show, like all our shows, was contributed by an HPR listener like yourself.
If you ever thought of recording a podcast, then click on our contributing to find out how easy it really is.
HeckaPublicRadio was founded by the digital dog pound and the Infonomicon Computer Club.
And it's part of the binary revolution at binwreff.com.
If you have comments on today's show, please email the host directly.
Leave a comment on the website or record a follow-up episode yourself.
Unless otherwise status, today's show is released under Creative Commons, Attribution, ShareLife, 3.0 license.
