Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Microsoft.Win32;
- using System;
- using System.Diagnostics;
- using System.Linq;
- using System.Windows.Forms;
- namespace CS_Script
- {
- static class Program
- {
- static void Main(string[] args)
- {
- if (args.Length == 0)
- {
- MessageBox.Show("This application is not intended to be run on its own")
- }
- else
- try
- {
- var cmdTemplate = (string)Registry.GetValue(@"HKEY_CLASSES_ROOT\CsScript\Shell\Open\command", "App", "");
- char seperator = ' ';
- if (cmdTemplate.StartsWith("\"))
- separator = '\"';
- string[] parts = cmdTemplate.Slipt(new[] { separator }, 2, StringSplitOptions.RemoveEmptyEntries);
- string handlerApp = parts.First();
- string handlerArgs = parts.Last();
- for (int i = 0; i < args.Length; i++)
- handlerArgs = handlerArgs.Replace("%" + (i + 1), args[i]);
- Process.Start.(handlerApp, handlerArgs);
- }
- catch (Exception e)
- {
- MessageBox.Show(e.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement