public static void addFirewall(string appPath) { StringBuilder strCMD = new StringBuilder(); string appName = ToolForUrl.getDirEndName(appPath, true); strCMD.AppendFormat("/netsh advfirewall firewall add rule name=\"{0}\" dir=in action=allow program=\"{1}\" enable=yes", appName, appPath); cmd(strCMD.ToString(), true); }
public static void deleteFirewall(string appPath) { StringBuilder strCMD = new StringBuilder(); string appName = ToolForUrl.getDirEndName(appPath, true); strCMD.AppendFormat("netsh advfirewall firewall delete rule name=\"{0}\" program=\"{1}\"", appName, appPath); cmd(strCMD.ToString(), true); }
public static void CreateShortcut() { string appName = AppDomain.CurrentDomain.SetupInformation.ApplicationName; string appDir = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; //string linkPath = StartUpPath + ToolForUrl.filterEnd(appName) + ".lnk"; //string targetPath = appDir + appName; //if (File.Exists(linkPath)) // return; StringBuilder strCmd = new StringBuilder(); strCmd.AppendFormat("set \"exe={0}\"\r\n", appName); strCmd.AppendFormat("set \"lnk={0}\"\r\n", ToolForUrl.filterEnd(appName)); strCmd.Append("mshta VBScript:Execute(\"Set a=CreateObject(\"\"WScript.Shell\"\"):"); strCmd.Append("Set b=a.CreateShortcut(a.SpecialFolders(\"\"Startup\"\") & \"\"\\%lnk%.lnk\"\"):"); strCmd.AppendFormat("b.TargetPath=\"\"{0}%exe%\"\":b.WorkingDirectory=\"\"{0}\"\":b.Save:close\")", appDir); cmd(strCmd.ToString(), true); }