I had a simple batch file I would use in Windows XP to create a set of specific subfolders inside a folder. I had it set up as a Right-Click context menu so that when I right-clicked on a folder within Windows Explorer, I could execute the batch file and have the 10 specific folders created inside it.
I moved the same batch file to Windows 7. I can run the batch file manually and it works fine, however when I run it from the Right-click context menu, the folders are all created in the \Windows\System32\ directory, not in the colder that I had right-clicked upon.
I know that the "Current Directory" in Windows XP used to carry the value of the right-clicked folder, now in Windows 7 the Current Directory value seems to change to the System32 folder.
I was trying to find a way to read the current directory that the mouse right-clicked on, but cannot find that value. "CD" is the System32 folder at the start of the batch execution.
Any suggestions?
Answer
You can change the command
entry in the registry to add a parameter:
C:\Users\Me\Batches\make_dir.cmd "%1"
and then use that parameter in the batch file:
cd /d "%1"
md SomeDirectory
md SomeOtherDirectory
As for the confusion, I guess the working directory of the process that is started for a shell command was never really specified so it could be anything. And Windows 7 introduced libraries which probably could lead to folders residing in »non-paths«.
No comments:
Post a Comment