FG
💻 Software

How do I set an executable's working directory via the command line, prior to executing it?

Fresh5 days ago
Mar 15, 2026135082 views
Confidence Score1%
1%

Problem

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.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I set an executable's working directory via the command line, prior to executing it?

Low Risk

To explicitly set the working directory, a PowerShell solution would be to use the cmdlet with the parameter. Using the alias , positional parameter, and partial parameter name this could be written as: CMD also has a command. For this, use the parameter to specify the working directory:

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment