- Joined
- Mar 25, 2012
- Messages
- 909
- Reaction score
- 464
Just programmed a little tool in the school via Teamviewer on my PC at home in Visual Studio (.NET 4.5, should work with 3.5, too). I won't count on a big nice design, since it's a quick ride. Just shared it, cuz I think this might be useful to most of you, lol.
Yes, it does exactly what you think it does, lol.
- Create a new Visual Studio console application project and add a reference to System.Windows.Forms (for the clipboard function).
- Paste this in the Program.cs:
- Compile and place anywhere
- Open CMD as admin and navigate to the directory of the tool
Use the following commands to register / unregister the application:
Have fun lol
Yes, it does exactly what you think it does, lol.
- Create a new Visual Studio console application project and add a reference to System.Windows.Forms (for the clipboard function).
- Paste this in the Program.cs:
PHP:
class Program
{
[STAThread]
static void Main(string[] args)
{
string[] paramList = Environment.GetCommandLineArgs();
if (paramList != null && paramList.Length > 1 && paramList[1].Length > 1)
{
string param = paramList[1].Trim('"').Trim();
if (param.Length == 2 && (param[0] == '-' || param[0] == '/'))
{
string name = paramList.Length > 2 && paramList[2] != null && paramList[2].Length > 0 ? paramList[2] : "Copy path to clipboard";
switch (param[1].ToString().ToLower()[0])
{
case 'i':
RegistryKey rki = Registry.LocalMachine.CreateSubKey("SOFTWARE").CreateSubKey("Classes").CreateSubKey("*").CreateSubKey("shell");
try { rki.DeleteSubKeyTree("Path2Clipboard"); }
catch { }
rki = rki.CreateSubKey("Path2Clipboard");
rki.SetValue("", name, RegistryValueKind.String);
rki = rki.CreateSubKey("command");
rki.SetValue("", "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\" \"%1\"", RegistryValueKind.String);
Console.WriteLine("Successfull registered.");
break;
case 'u':
RegistryKey rku = Registry.LocalMachine.OpenSubKey("SOFTWARE", true).OpenSubKey("Classes", true).OpenSubKey("*", true).OpenSubKey("shell", true);
try
{
rku.DeleteSubKeyTree("Path2Clipboard");
Console.WriteLine("Successfull unregistered.");
}
catch { }
break;
}
}
else if (param.Length > 2)
{
Clipboard.SetText(param);
}
}
}
}
- Compile and place anywhere
- Open CMD as admin and navigate to the directory of the tool
Use the following commands to register / unregister the application:
Code:
Register with "Copy path to clipboard" entry name: Path2Clipboard.exe -i
Register with custom entry name: Path2Clipboard.exe -i "Copy path"
Unregister again: Path2Clipboard.exe -u
Have fun lol
Last edited: