10

What is the difference between Current Directory and Working Directory in Windows? How can one change working Directory for applications like Notepad++ or Mozilla Firefox?

user2024398
  • 101
  • 1
  • 1
  • 3

1 Answers1

7

Current directory and working directory are just two different names for the same thing. Each process maintains a single current directory.

The current directory is specified on startup as a parameter to whichever function is used to create the process, for example CreateProcess. How do you change the current directory for one of your applications? Well, it depends how you start it.

  • If you start it from a shortcut, change the properties of the shortcut to specify the current directory.
  • If you start from a command prompt, the current directory will be the current directory of the command prompt at the moment that you start it.
  • If you start by calling CreateProcess, the working current will be whatever you pass to CreateProcess in the lpCurrentDirectory parameter. If you pass NULL then the current directory of the parent process will be used.
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • When I start Notepad++ from shortcut I see the current Directory in Process Explorer. I see it as C:\Windows. When I do a createProcess and set some valid Directory(say D:\abcd) in lpCurrentDirectory field, it is still showing C:\Windows. Shouldn't it show D:\abcd? – user2024398 Mar 11 '13 at 11:36
  • Well, remember that a process can modify its own current directory any time it likes. Perhaps npp is doing that. I don't know. It's also possible that there's a flaw in your `CreateProcess` call. – David Heffernan Mar 11 '13 at 11:42
  • Thanks :)... I'm sorry I'm unable to upvote your answer because I'm new to Stackoverflow and my reputation is below 15 points. I will do it once I get them. – user2024398 Mar 12 '13 at 06:05
  • @DavidHeffernan, Re "*If you start it from a shortcut, change the properties of the shortcut to specify the current directory*"; But how do you do that? – Pacerier Apr 11 '16 at 16:39
  • @Pacerier Right click on the shortcut, select properties, and edit the Start in field. – David Heffernan Apr 11 '16 at 16:49