I'm building a custom explorer treeview that only has my code repository, my visual studio projects folder, and other similar things for quick access, and possibly eventually on-the-fly version comparing. I'd like to be able to right click a folder in this explorer and get a cmd.exe prompt here, like in windows explorer with the powertoy. Any ideas? cmd.exe /k opens a prompt and leaves it open, but I can't find any flags or text to pipe into it to start at a specific drive or folder.
A:
Try setting the tag property of the treenode to contain the entire folder path.
Then you can easily construct your code that opens the command prompt window to inject the proper file location. This will also allow you to easily add/edit nodes on the fly.
Dillie-O
2009-05-15 22:04:29
yeah I'm doing that part, just didn't know a way to make good use of that path for starting a command prompt
Maslow
2009-05-15 23:04:59
+2
A:
It seems like there should be another way to do this, but you can pass commands to be executed as command-line parameters to cmd:
cmd /k "cd c:\myDirectory"
Michael Petrotta
2009-05-15 22:06:28
I thought so too, so I checked out how the PowerToy works, and it does exactly this! The registry setting is:HKEY_CLASSES_ROOT\Directory\shell\cmd\command; the command is:cmd.exe /k "cd %L"
overslacked
2009-05-15 22:09:43
+2
A:
You just need to set the working directory :
Dim psi As New ProcessStartInfo("c:\Windows\System32\cmd.exe", "/k")
psi.WorkingDirectory = "<path of the selected directory>"
Process.Start(psi)
Thomas Levesque
2009-05-15 22:10:14