Jun 18, 2010 05:59 AM
(This post was last modified: Jun 18, 2010 07:05 AM by ubbelol.)
Hey! A guy asked me on msn yesterday how you would add an item to the windows default right click menu when you right click any .exe file, so i googled up what registry keys had to be created and here's what i came up with. It's a simple function let you add your own item to the right click menu of executable files. (Thanks nathan my drunk friend for giving me an example on how to change the default value of a subkey :p)
Btw this require UAC to work.
To use the function:
I added the ArgumentArray for people using console applications and wanting to open, edit, delete or modify the file in any way. Please read my tutorial on passing arguments to a console application here: https://hackforums.net/showthread.php?tid=488166
If you do not know how to create a simple string array with arguments, here's an example:
Another neat little thing i discovered is that if you add an argument like this:
the "-%1" will return the full path of the file you right clicked! 😉
Here is a picture of when passing the "%1" argument to a console application:
[IMG]http://i350.photobucket.com/albums/q408/ubbe12/asfsfaaf.png[/IMG]
Thats it! :p Hope you can read my awful english.
Btw this require UAC to work.
Code
Private Function doAddToList(ByVal itemName As String, ByVal itemPath As String, ByVal itemArgs() As String)
Dim regkey : regkey = CreateObject("wscript.shell") : Dim keyValue = Chr(34) & itemPath & Chr(34)
If Not itemArgs.Length < 1 Then
For i = 0 To itemArgs.Length - 1
keyValue &= itemArgs(i)
Next
End If
Try
regkey.regwrite("HKEY_CLASSES_ROOT\*\shell\" & itemName & "\command\", keyValue, "REG_SZ")
Catch
Return False
End Try
Return True
End FunctionTo use the function:
Code
If doAddToList("Item Name", "File Path", ArgumentArray) Then
MsgBox("Success!") ' Successfully added item
Else
MsgBox("Fail!") ' Failed to add item
End IfI added the ArgumentArray for people using console applications and wanting to open, edit, delete or modify the file in any way. Please read my tutorial on passing arguments to a console application here: https://hackforums.net/showthread.php?tid=488166
If you do not know how to create a simple string array with arguments, here's an example:
Code
dim argArray() as string = new string() {"-arg1", "-arg2", "-arg3"}Another neat little thing i discovered is that if you add an argument like this:
Code
dim argArray() as string = new string() {"-%1", "-arg2", "-arg3"}the "-%1" will return the full path of the file you right clicked! 😉
Here is a picture of when passing the "%1" argument to a console application:
[IMG]http://i350.photobucket.com/albums/q408/ubbe12/asfsfaaf.png[/IMG]
Thats it! :p Hope you can read my awful english.
Probably coding some useless shit.


