Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Executing command line command anywhere ?

25 Mar 2015   #1

Windows 10 Pro
Executing command line command anywhere ?

I want to create a setup whereas a command line command can be run from any directory/folder, without having to be in the directory/folder whereas the command line command resides ?

My System SpecsSystem Spec
25 Mar 2015   #2

Windows 10 Pro X64

Add the directory the cmd or bat files resides in to the PATH environment variable.
To check or modify the system PATH environment variable, do the following:

XP: Right clock on My Computer
Vista, 7: Right click on Computer
Windows 8, 10: Right click on This PC

Select Properties

Vista, 7, 8, 10: Click on Advanced System Properties on the left

On the Advanced tab, click on Environment Variables
Under System Variables, scroll down to Path
Select it then click Edit

An easy way to look at all of it is to right click on the highlighted Variable Value field and select copy, then start Notepad and paste the data into there. That way you can easily look at all of it.

It's also a lot easier to make changes in Notepad then copy and paste the changed data back into the Path Variable Value field.

Click Ok as needed to exit when done
My System SpecsSystem Spec
26 Mar 2015   #3

Windows 10 Pro

Ahhh thanks I was thinking something along the line at the time was drawing blanks
My System SpecsSystem Spec

28 Mar 2015   #4

Windows 7 Ultimate x64

Two more alternative ways without tweaking system-wide settings.

Use push/popd to temporarily change current directory and run it from there (with the examples taking starting excel 2010 as my test piggy):

pushd "c:\program files\microsoft office\office14"
Or specifiy the full path in the call:

"c:\program files\microsoft office\office14\excel.exe"
My System SpecsSystem Spec
29 Mar 2015   #5

Windows 10 Pro

Interesting Alejandor, I assume if you restart your computer you have to use the Push command again to store the directory, little easier to store it as a system wide setting, this way, you can run the command in any directory
My System SpecsSystem Spec

 Executing command line command anywhere ?

Thread Tools

Similar help and support threads
Thread Forum
Command Line - Help
Hi Guy's and Girls, Just first off I've never been too good with CMD and only an Apprentice in my company I work for. Now something I've wanted to do for awhile was to make the following but I don't necassirealy I know how to do this in one batch file: I would need a Batch file that is...
General Discussion
What is wrong with this command line?
Help please I am pulling my hair out. I use a desktop shortcut to run an application called get_iplayer.cmd located in the directory c:\program files\get_iplayer The line in the Target of the shortcut properties therefore reads: C:\Windows\System32\cmd.exe /k "c:\program...
General Discussion
Gpedit via command line
how can I enable disable a policy using gpedit! Not via the GUI, you go do some clicks and enable. But I want to execute one shot command which will say disable AutoRun. I have searched exenstively, no results. I kind need this for my automation stuff. Thanks, Akshay
Performance & Maintenance
Command Line
Is there a cmd.exe /switch for “run as administrator” ? Thanks-
General Discussion
Can you boot from the command line?
This is an off topic thread because it concerns WinXP/2000 dual boot machine which are not booting. I can get to the Windows\ and Winnt command line of each but trying to figure out if I can boot from there. If I try to boot regularly I get "missing operating system" Im trying the Windows 2000...
Chillout Room

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 00:51.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App