How can we pass options to programs being called through edits to the windows registry using regedit.exe? This is a syntax question as far as I can tell.
For example... I have recently added a new program to my windows/system32 folder called sDelete.exe. It is a secure delete program available from Microsofts sysinternals
From the website: SDelete implements the Department of Defense clearing and sanitizing standard DOD 5220.22-M, to give you confidence that once deleted with SDelete, your file data is gone forever. Note that SDelete securely deletes file data, but not file names located in free disk space.
So I wanted to add a context menu entry in Windows 7 when I right click on a file. So far I can delete a program from the context menu but only I call it without passing options parameters.
- windowKey + R: Opens run window; Type regedit.exe to open the registry editor
- go down to HKEY_CLASSES_ROOT*\shell\
- Make a new Key called "sDelete: 3 Passes"
- Right Click on the new Key and Create another new Key, name it "command".
- Double click on (Default) and enter the following command "c:\\windows\\system32\\sdelete.exe" "%1"
(Update: Solution Below)
At this point I can right click on a file and secure delete it but the default is only 1 pass. I am way too unjustifiably paranoid to accept this behaviour. Now I have tried a few different things to pass the parameter option that specifies the number of passes I want sDelete to perform. Say "-p 3" for example would specify three passes.
I can't figure out how to make this work though. I thought I had it but then realized that it wasn't right.
How can we pass option parameters to a call to a program though a context menu in this manner?
UPDATE: THE PROBLEM IS WITH THE SYNTAX FOR THE PARAMETERS.
I figured it out. I was doing what you suggested, as well as a variety of variations but nothing would work. "-p 3" would not work, I would get an error or a window would open up asking me to specify a program to open it with.
- Double click on (Default) and enter the following command
USE "c:\\windows\\system32\\sdelete.exe" "-p" "3" "%1"
not "c:\\windows\system32\\sdelete.exe" "-p 3" "%1"
and not "c:\\windows\\system32\\sdelete.exe -p 3" "%1"
and not "c:\\windows\\system32\\sdelete.exe -p 3%1"
and not c:\\windows\\system32\\sdelete.exe -p 3%1
Notice that including whitespace causes problems. This makes sense if actually. Windows is ignoring the whitespace but when the space is included inside a string the program is just matching the string to a limited predetermined list. Exact matches are expected. "-p 3" is not equal to "-p" "3". When matching a parameter the string "-p 3" there is no option called "p 3". Rather we should give the option "-p" to tell the program to 'listen' for a value to pass to the program. If it does not start with a - symbol then the program interprets it as a filename.
So separating all the arguments you that would normally be parsed out of the string you type into the cmd input is the way to properly initialize them.