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
How to use the reg command line statement
There is a small batch file I would like to execute. I have cut and pasted it from another source. The batch file failed repeatedly. Then I attempted to run the statements individually at the command prompt. Things still failed. Example: reg load HKLM\MY_SYSTEM followed by a command...
General Discussion
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
UAC bug with runas from command line?
Hi Folks, I am experiencing what I believe is a bug with UAC in Windows 7. I would like to see if anyone can recreate this issue and tell me if it is a bug or is working as expected. To recreate the issue: 1. Confirm the following local security policy setting is Enabled. Local Policies...
General Discussion
libraries and the command line
I am a long time programmer and computer science professor, since 1979. I grew up with the command line and like it just fine. But Windows 7 seems to change the GUI way of doing things and not mess with the command line. Yesterday I was at the command prompt and went to C:\users\Stockwell and...
Performance & Maintenance
Command Line
Is there a cmd.exe /switch for “run as administrator” ? Thanks-
General Discussion

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 06:15.
Twitter Facebook Google+