2

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

http://technet.microsoft.com/en-us/sysinternals/bb897443

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.

  1. windowKey + R: Opens run window; Type regedit.exe to open the registry editor
  2. go down to HKEY_CLASSES_ROOT*\shell\
  3. Make a new Key called "sDelete: 3 Passes"
  4. Right Click on the new Key and Create another new Key, name it "command".
  5. 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.

1
  • As soon as you're allowed to do so you should edit out the answer from your question above and add it below.
    – Karan
    Commented Apr 29, 2013 at 12:49

1 Answer 1

0

You just include the parameters in the command line you enter in the registry key. The syntax depends entirely on the command you run. If "-p 3" is what SDelete wants, it should work. Consult the SDelete documentation if it doesn't.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .