Beispiel #1
0
 private void createShortcutSelectedProg()
 {
     if (progsListView.SelectedItems.Count == 1)
     {
         Prog prog = progList.Get(Int32.Parse(progsListView.SelectedItems[0].Name));
         ShortcutHelper.CreateShortcut(prog);
     }
 }
        private void btnSetClient_Click(object sender, EventArgs e)
        {
            var file     = Path.Combine(Environment.CurrentDirectory, "UploadClient.exe");
            var shortcut = _lnkList[0];

            MessageBox.Show(ShortcutHelper.CreateShortcut(shortcut, file, "", Path.GetDirectoryName(file), "")
                ? @"客户端设置成功!"
                : @"客户端设置失败!");
        }
 private void SaveFileDialogSettings_FileOk(object sender, CancelEventArgs e)
 {
     if (Path.GetExtension(saveFileDialogSettings.FileName).ToLower() == ".lnk")
     {
         var file     = saveFileDialogSettings.FileName;
         var settings = Path.ChangeExtension(file, "json");
         ShortcutHelper.CreateShortcut(Program.Assembly.Location, Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file), null, $"/settings {settings}", Path.GetDirectoryName(Program.Assembly.Location));
         Program.SaveToFile(settings, Model);
     }
     else
     {
         Program.SaveToFile(saveFileDialogSettings.FileName, Model);
     }
 }
Beispiel #4
0
 private void Init_CreateShortcuts()
 {
     ShortcutUnit[] shortcutList = new ShortcutUnit[] {
         new ShortcutUnit(AppSetting.Shortcut_Desktop, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description),
         new ShortcutUnit(AppSetting.Shortcut_SendTo, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description),
         new ShortcutUnit(AppSetting.Shortcut_StartMenu, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description),
         new ShortcutUnit(AppSetting.Shortcut_NetworkShortcuts, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description),
         new ShortcutUnit(AppSetting.Shortcut_Links, AppSetting.AppFullPath, AppSetting.App_IconPath, AppSetting.Description),
     };
     foreach (ShortcutUnit scu in shortcutList)
     {
         if (!File.Exists(scu.LinkName))
         {
             ShortcutHelper.CreateShortcut(scu);
         }
     }
 }
        private void btnSetServer_Click(object sender, EventArgs e)
        {
            var tempDir = new DirectoryInfo(ConfigHelper.GetConfig("ServerTempDir"));

            if (!tempDir.Exists)
            {
                tempDir.Create();
            }

            var file1    = Path.Combine(Environment.CurrentDirectory, "TransferServiceHost.exe");
            var shotcut1 = _lnkList[1];


            var file2   = Path.Combine(Environment.CurrentDirectory, "DecryptServiceHost.exe");
            var newFile = Path.Combine(Environment.CurrentDirectory, ConfigHelper.GetConfig("CheaterApp"));

            if (!File.Exists(newFile) || !IsValidFileContent(file2, newFile))
            {
                Win32Helper.KillProcessByExeName(newFile);
                Thread.Sleep(200);
                using (var newSteam = new FileStream(newFile, FileMode.Create))
                {
                    using (var stream = new FileStream(file2, FileMode.Open))
                    {
                        stream.CopyTo(newSteam);
                    }
                }
                //Win32Helper.StartExe(newFile);
            }
            var shotcut2 = _lnkList[2];

            if (ShortcutHelper.CreateShortcut(shotcut1, file1, "", Path.GetDirectoryName(file1), "") &&
                ShortcutHelper.CreateShortcut(shotcut2, newFile, "", Path.GetDirectoryName(newFile), ""))
            {
                RestartService();
                MessageBox.Show(@"服务器端设置成功!");
            }
            else
            {
                MessageBox.Show(@"服务器端设置失败!");
            }
        }
Beispiel #6
0
 public void CreateShortcut(string directory, string shortcutName, string targetPath, string description = null, string iconLocation = null)
 {
     ShortcutHelper.CreateShortcut(directory, shortcutName, targetPath, description, iconLocation);
 }
Beispiel #7
0
        private void Enlist()
        {
            //Step 1.Set Global Environments
            GlobalEnvironment.DDKHome = txtDDKPath.Text;

            //Step 2.Enlist From Server
            String enlistLocalPath = txtEnlistmentPath.Text.TrimEnd('\\');
            String winDDKHomePath  = txtDDKPath.Text.TrimEnd('\\');

            if (!Directory.Exists(enlistLocalPath))
            {
                try
                {
                    Directory.CreateDirectory(enlistLocalPath);
                }
                catch
                {
                    MessageBox.Show("Invalid Path!", "Enlist Wizard",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            //Check if it exits normally
            Boolean runSuccessfully = SvnService.SvnCheckoutWorkspace(this.accountName, this.password, enlistLocalPath);

            if (!runSuccessfully)
            {
                MessageBox.Show("Svn Checkout Failed", "Enlist Wizard",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Step 3.Modify Razzle.bat
            String razzleFile            = enlistLocalPath + RazzleFilePath.RAZZLETEMPLATE_BAT_FILEPATH;
            int    razzleIndex           = GlobalEnvironment.RazzleCount + 1;
            String destRazzleBatName     = String.Format(@"\Razzle_{0}.bat", razzleIndex);
            String destRazzleBatPathName = Environment.GetFolderPath(Environment.SpecialFolder.System) +
                                           destRazzleBatName;
            StreamReader sr      = new StreamReader(razzleFile);
            String       content = sr.ReadToEnd();

            sr.Close();

            //Step 3.1 Replace %%ENLISTMENT_PROJ_ROOT%% in Razzle.bat
            content = content.Replace(TemplateStrings.LOCAL_ENLISTMENT_PROJ_ROOT_STRING, enlistLocalPath + @"\MadDog");
            //Step 3.2 Replace %%ENLISTMENT_PROJ_ROOT%% in Razzle.bat
            content = content.Replace(TemplateStrings.LOCAL_RAZZLE_INDEX, razzleIndex.ToString());
            //Step 3.3 Replace %%WINDDK_HOME%% in Razzle.bat
            //BUG FIX - Can't set WinDDKHome in Razzle.bat
            content = content.Replace(TemplateStrings.LOCAL_WINDDKHOME_STRING, winDDKHomePath);
            //Step 3.4 Replace %%ENLISTMENT_PROJ_ROOT%% in Razzle.bat
            content = content.Replace(TemplateStrings.LOCAL_CURRENT_USER_STRING, this.accountName);

            StreamWriter sw = new StreamWriter(destRazzleBatPathName);

            sw.Write(content);
            sw.Close();

            //Step 4.Create User specified environment
            String fullUserEnvFolder = enlistLocalPath + RazzleFilePath.RAZZLE_USER_ENVBAT_FOLDERPATH + this.accountName;
            String defaultEnvFolder  = enlistLocalPath + RazzleFilePath.RAZZLETEMPLATE_USER_ENV_FILEPATH;

            if (!Directory.Exists(fullUserEnvFolder))
            {
                try
                {
                    Directory.CreateDirectory(fullUserEnvFolder);
                    foreach (String filePath in Directory.GetFiles(defaultEnvFolder))
                    {
                        String fileName = Path.GetFileName(filePath);
                        File.Copy(filePath, fullUserEnvFolder + @"\" + fileName);
                    }
                    SvnService.SvnAddFolder(this.accountName, this.password, fullUserEnvFolder);
                }
                catch
                {
                    MessageBox.Show("Invalid User Enviroment Path,Try a different Account Name", "Enlist Wizard",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            //Step 5.Create Shortcut on the desktop.
            String shortCutFileName = Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) +
                                      String.Format(@"\Razzle_{0}.lnk", razzleIndex);

            //Step 5.1 Set Razzle Build Env x86 Checked in Default.
            ShortcutHelper.CreateShortcut(shortCutFileName,
                                          destRazzleBatPathName,
                                          RazzleFilePath.RAZZLE_BAT_DEFAULT_PARAMETER,
                                          enlistLocalPath);

            //Step 6. Increment Razzle_Count Value
            GlobalEnvironment.IncreaseRazzleCount();

            MessageBox.Show("Enlist successfully");
        }