Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I run a program on the command line whose location is resolved through the Path environment variable, the program's working directory is generally set to its installation directory.

I would like to run such a program from a console window and set its working directory to the current or other explicit directory. I was able to do this by temporarily copying the program to my working directory -- is there another way to accomplish this within the cmd.exe or powershell.exe environments?

The windows shell analogy to this task is to create a shortcut and set the "Start In" property accordingly.

share|improve this question

2 Answers 2

up vote 10 down vote accepted

To explicitly set the working directory, a PowerShell solution would be to use the Start-Process cmdlet with the -WorkingDirectory parameter.

Start-Process -FilePath notepad.exe -WorkingDirectory c:\temp

Using the alias start, positional parameter, and partial parameter name this could be written as:

start notepad.exe -wo c:\temp
share|improve this answer

The below will work, make appropriate substitutions and save it with a .cmd extension.

@echo off 
chdir C:\desired\directory

Put this batch file in a directory in your %PATH% and you should be able to invoke it from any cmd.exe instance.

share|improve this answer
Note that funkiness may occur if the working directory and executable aren't on the same partition/drive. –  MBraedley Mar 3 '12 at 2:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.