Example #1
0
        private void WriteShortcut(ProjectFile location, ProjectFile item)
        {
            var wsh = new IWshRuntimeLibrary.IWshShell_Class();

            IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(location.FullFilePath) as IWshRuntimeLibrary.IWshShortcut;
            shortcut.TargetPath = item.FullFilePath;
            shortcut.Save();
        }
Example #2
0
            /// <summary>
            /// 指定したフォルダに登録されているスタートアップを取得
            /// </summary>
            /// <param name="startup_information">スタートアップ情報</param>
            /// <param name="startup_register_place">登録情報</param>
            /// <param name="startup_folder_path">パス</param>
            private static void GetDesignationFolder(
                ref System.Collections.Generic.List <StartupInformation> startup_information,
                StartupRegisterPlace startup_register_place,
                string startup_folder_path
                )
            {
                try
                {
                    string[] file_path = System.IO.Directory.GetFiles(startup_folder_path, "*.lnk", System.IO.SearchOption.TopDirectoryOnly);      // ファイルパス

                    foreach (string now_file_path in file_path)
                    {
                        try
                        {
                            IWshRuntimeLibrary.IWshShell_Class    shell    = new IWshRuntimeLibrary.IWshShell_Class();
                            IWshRuntimeLibrary.IWshShortcut_Class shortcut = (IWshRuntimeLibrary.IWshShortcut_Class)shell.CreateShortcut(now_file_path);
                            StartupInformation new_startup_information     = new StartupInformation
                            {
                                Path             = shortcut.TargetPath,
                                RegisterName     = System.IO.Path.GetFileNameWithoutExtension(shortcut.FullName),
                                Parameter        = shortcut.Arguments,
                                WorkingDirectory = shortcut.WorkingDirectory,
                                RegisterPlace    = startup_register_place
                            };

                            switch (shortcut.WindowStyle)
                            {
                            case 1:
                                new_startup_information.WindowState = WindowState.Normal;
                                break;

                            case 3:
                                new_startup_information.WindowState = WindowState.Maximized;
                                break;

                            case 7:
                                new_startup_information.WindowState = WindowState.Minimized;
                                break;
                            }
                            startup_information.Add(new_startup_information);
                        }
                        catch
                        {
                        }
                    }
                }
                catch
                {
                }
            }
Example #3
0
        public static void CreateStartupShortcut()
        {
            IWshRuntimeLibrary.IWshShell_Class wshShell = new IWshRuntimeLibrary.IWshShell_Class();
            IWshRuntimeLibrary.IWshShortcut    shortcut;
            string startUpFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

            // Create the shortcut
            shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(startUpFolderPath + "\\ChromiumUpdater.lnk");

            shortcut.TargetPath       = Process.GetCurrentProcess().MainModule.FileName;
            shortcut.WorkingDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
            shortcut.Description      = "Launch Chromium updater";
            shortcut.IconLocation     = Environment.CurrentDirectory + @"\Refresh2.ico";
            shortcut.Save();
        }
Example #4
0
 /// <summary>
 /// Create a new shortcut file
 /// </summary>
 /// <param name="targetFile">The shortcut file's path</param>
 /// <param name="linkedFile">The file to point the shortcut to</param>
 private void CreateShortcut(string targetFile, string linkedFile)
 {
     try
     {
         IWshRuntimeLibrary.IWshShell_Class wsh      = new IWshRuntimeLibrary.IWshShell_Class();                        //Get a new shell
         IWshRuntimeLibrary.IWshShortcut    shortcut = (IWshRuntimeLibrary.IWshShortcut)wsh.CreateShortcut(targetFile); //Create the shortcut object
         shortcut.TargetPath       = linkedFile;                                                                        //Set the target path
         shortcut.WorkingDirectory = Application.StartupPath;                                                           //Set the working directory important!!
         shortcut.Save();                                                                                               //Save the object (write to disk)
                                                                                                                        //Console.WriteLine("Shortcut created");
     }
     catch (Exception ex)                                                                                               //Failed to create shortcut
     {
         Console.WriteLine("Error creating shortcut: " + ex.Message);
     }
 }
Example #5
0
            /// <summary>
            /// フォルダに登録
            /// </summary>
            /// <param name="startup_register_place">スタートアップの登録場所</param>
            /// <param name="register_name">登録名</param>
            /// <param name="file_path">ファイルパス</param>
            /// <param name="parameter">パラメータ</param>
            /// <param name="window_state">ウィンドウの状態</param>
            /// <param name="working_directory">作業ディレクトリ</param>
            private static void RegisterFolder(
                StartupRegisterPlace startup_register_place,
                string register_name,
                string file_path,
                string parameter,
                WindowState window_state,
                string working_directory
                )
            {
                string startup_folder_path = null;          // スタートアップフォルダのパス

                switch (startup_register_place)
                {
                case StartupRegisterPlace.FolderLogonUser:
                    startup_folder_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup);
                    break;

                case StartupRegisterPlace.FolderAllUser:
                    startup_folder_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonStartup);
                    break;
                }
                startup_folder_path += "\\" + register_name + ".lnk";

                IWshRuntimeLibrary.IWshShell_Class    shell    = new IWshRuntimeLibrary.IWshShell_Class();
                IWshRuntimeLibrary.IWshShortcut_Class shortcut = (IWshRuntimeLibrary.IWshShortcut_Class)shell.CreateShortcut(startup_folder_path);

                shortcut.TargetPath = file_path;
                shortcut.Arguments  = parameter;
                switch (window_state)
                {
                case WindowState.Normal:
                    shortcut.WindowStyle = 1;
                    break;

                case WindowState.Maximized:
                    shortcut.WindowStyle = 3;
                    break;

                case WindowState.Minimized:
                    shortcut.WindowStyle = 7;
                    break;
                }
                shortcut.WorkingDirectory = working_directory;
                shortcut.Save();
            }
Example #6
0
 protected void CreateShortcuts(String targetPath, String savePath, String saveName)
 {
     IWshRuntimeLibrary.IWshShell    shell_class = new IWshRuntimeLibrary.IWshShell_Class();
     IWshRuntimeLibrary.IWshShortcut shortcut    = null;
     //if (!Directory.Exists(targetPath))
     //    return;
     if (!Directory.Exists(savePath))
     {
         Directory.CreateDirectory(savePath);
     }
     try {
         shortcut            = shell_class.CreateShortcut(savePath + @"/" + saveName + ".lnk") as IWshRuntimeLibrary.IWshShortcut;
         shortcut.TargetPath = targetPath;
         shortcut.Save();
         //MessageBox.Show("创建快捷方式成功!");
     } catch (Exception ex) {
         //MessageBox.Show("创建快捷方式失败!");
     }
 }
 public void GenerateShortcuts()
 {
     try
     {
         string directory = Services.PathService.GetShortcutsPath();
         foreach (var entry in Directory.EnumerateFiles(directory))
         {
             File.Delete(entry);
         }
         foreach (var workspace in Classes.Settings.Default.Workspaces)
         {
             var wsh = new IWshRuntimeLibrary.IWshShell_Class();
             IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(directory + string.Format("\\{0}.lnk", workspace.Name)) as IWshRuntimeLibrary.IWshShortcut;
             shortcut.TargetPath = workspace.Path;
             shortcut.Save();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Example #8
0
        private string GetShortcutTargetPath(string shortcutFilePath)
        {
            try
            {
                IWshRuntimeLibrary.IWshShell_Class    TheShell = new IWshRuntimeLibrary.IWshShell_Class();
                IWshRuntimeLibrary.IWshShortcut_Class shortcut;
                shortcut = (IWshRuntimeLibrary.IWshShortcut_Class)TheShell.CreateShortcut(shortcutFilePath);

                string targetPath = shortcut.TargetPath;
                string ext        = Path.GetExtension(targetPath);
                if (ext == ".lnk")
                {
                    throw new Exception("target path is .lnk");                  // LoadFileOrDirectory()時の、無限ループ防止
                }
                else
                {
                    return(shortcut.TargetPath);
                }
            }
            catch
            {
                return("");
            }
        }
Example #9
0
        private void InitShortcuts()
        {
            string installDir  = (string)Registry.GetValue(keyName, "installDir", "Not Exist");
            string packageDir  = (string)Registry.GetValue(keyName, "packageDir", "Not Exist");
            string shortcutDir = (string)Registry.GetValue(keyName, "shortcutDir", "Not Exist");

            /*
             * try
             * {
             *  ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, policy) =>
             *  {
             *      return true;
             *  };
             * }
             * catch (Exception ex)
             * {
             *  eventLog1.WriteEntry(ex.Message);
             * }//*/
            WebClient myWebClient = new WebClient();

            try
            {
                string serverDir = (string)Registry.GetValue(keyName, "serverDir", "Not Exist");
                myWebClient.DownloadFile(serverDir + "/packages.txt", packageDir + "\\packages.txt");
            }
            catch (Exception ex)
            {
                eventLog1.WriteEntry("Nastala chyba pri stahovani balicka " + ex.Message);
                return;
            }
            finally
            {
                if (myWebClient != null)
                {
                    myWebClient.Dispose();
                }
            }


            string[] packList = File.ReadAllLines(packageDir + "\\packages.txt");
            string   package  = "";
            string   path;

            string[] tmp;

            // pre kazdy balik spravime shortcut
            foreach (string line in packList)
            {
                //tmp = line.Split('~');
                tmp = line.Split(new string[] { "~~" }, StringSplitOptions.None);
                if (line[0] == 'p')
                {
                    package = tmp[1];
                    if (line[1] == 'a')
                    {
                        //tmp = line.Split(' ');
                        path = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + package + ".lnk";
                        var wsh = new IWshRuntimeLibrary.IWshShell_Class();
                        IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + package + ".lnk") as IWshRuntimeLibrary.IWshShortcut;
                        shortcut.Arguments  = package;
                        shortcut.TargetPath = installDir;
                        shortcut.Save();
                    }
                }
                if (line[0] == 's')
                {
                    path = shortcutDir + "\\" + tmp[1] + ".lnk";
                    var wsh = new IWshRuntimeLibrary.IWshShell_Class();
                    IWshRuntimeLibrary.IWshShortcut shortcut =
                        wsh.CreateShortcut(shortcutDir + "\\" + tmp[1] + ".lnk")
                        as IWshRuntimeLibrary.IWshShortcut;
                    shortcut.Arguments  = " \"" + package + "\" \"" + tmp[2] + "\"";
                    shortcut.TargetPath = System.IO.Path.Combine(installDir, "UserApp.exe");
                    shortcut.Save();
                }
            }
        }
        private void BTN_AUTOPATCHER_Click(object sender, EventArgs e)
        {
            DialogResult rs = MessageBox.Show("Make sure the game runs and all first-time setup programs have been completed, before executing this script\n Start Patcher?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            //If Messagebox input = yes run the autopatcher
            if (rs == DialogResult.Yes)
            {
                sconsole.LOG("AutoPatcher Started:");
                //do whatever autopatcher does :D
                if (File.Exists(GTAPATH.Text + @"\steam_api64.dll"))
                {
                    sconsole.LOG("Found Steam Version");
                    Thread.Sleep(200);
                    string s = Directory.GetCurrentDirectory();
                    if (!File.Exists(GTAPATH.Text + @"\GTA5.exe") ||
                        !File.Exists(GTAPATH.Text + @"\GTAVLauncher.exe") ||
                        !File.Exists(GTAPATH.Text + @"\steam_api64.dll") ||
                        !File.Exists(GTAPATH.Text + @"\update\update.rpf"))
                    {
                        sconsole.LOG("sry one of these files were not found\nGTA5.exe\nPlayGTAV.exe\nGTAVLauncher.exe\nsteam_api64.dll\nupdate.rpf");
                        MessageBox.Show("Please look at the LOG as we couldnt find a specific file");
                    }
                    else
                    {
                        sconsole.LOG("Backing Up Files");//Backing Up all important files,
                        File.Copy(GTAPATH.Text + @"\GTA5.exe", s + @"\Backup\Steam\GTA5.exe", true);
                        File.Copy(GTAPATH.Text + @"\GTAVLauncher.exe", s + @"\Backup\Steam\GTAVLauncher.exe", true);
                        File.Copy(GTAPATH.Text + @"\steam_api64.dll", s + @"\Backup\Steam\steam_api64.dll", true);
                        File.Copy(GTAPATH.Text + @"\update\update.rpf", s + @"\Backup\Steam\update.rpf", true);

                        Process     p   = new Process();
                        RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Rockstar Games\Rockstar Games Social Club");
                        key.SetValue("Version", "1.0.0.0");
                        key.Close();

                        p.StartInfo.FileName = s + @"\common\uninstall.exe";
                        p.Start();
                        while (true)
                        {
                            if (p.HasExited)
                            {
                                sconsole.LOG("Rockstar Games Launcher probably has been sucessfully uninstalled");
                                break;
                            }
                            else
                            {
                                Thread.Sleep(500);
                            }
                        }
                        p.StartInfo.FileName = s + @"\Steam\Social-Club-v1.1.7.8-Setup.exe";
                        p.Start();
                        while (true)
                        {
                            if (p.HasExited)
                            {
                                sconsole.LOG("Social Club has probably been installed");
                                break;
                            }
                            else
                            {
                                Thread.Sleep(500);
                            }
                        }
                        Thread.Sleep(500);
                        sconsole.LOG("STEAM: Placing 1.27 patch files into GTA Directory");
                        if (File.Exists(GTAPATH.Text + "GTA5.exe"))
                        {
                            File.Delete(GTAPATH.Text + "GTA5.exe");
                        }
                        if (File.Exists(GTAPATH.Text + "GTAVLauncher.exe"))
                        {
                            File.Delete(GTAPATH.Text + "GTAVLauncher.exe");
                        }
                        if (File.Exists(GTAPATH.Text + "steam_api64.dll"))
                        {
                            File.Delete(GTAPATH.Text + "steam_api64.dll");
                        }
                        if (File.Exists(GTAPATH.Text + @"\update\update.rpf"))
                        {
                            File.Delete(GTAPATH.Text + @"\update\update.rpf");
                        }
                        File.Copy(s + @"\Steam\GTA5.exe", GTAPATH.Text + "GTA5.exe");
                        File.Copy(s + @"\Steam\GTAVLauncher.exe", GTAPATH.Text + "GTAVLauncher.exe");
                        File.Copy(s + @"\Steam\steam_api64.dll", GTAPATH.Text + "steam_api64.dll");
                        File.Copy(GTAPATH.Text + "GTAVLauncher.exe", GTAPATH.Text + "PlayGTAV.exe");

                        File.Copy(s + @"\Common\update.rpf", GTAPATH.Text + @"\update\update.rpf");

                        sconsole.LOG("Creating Shortcut");
                        var wsh = new IWshRuntimeLibrary.IWshShell_Class();
                        IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(
                            GTAPATH.Text + "\\GTAVLauncher.lnk") as IWshRuntimeLibrary.IWshShortcut;
                        shortcut.Arguments  = "-scOfflineOnly";
                        shortcut.TargetPath = GTAPATH.Text + "GTAVLauncher.exe";
                        shortcut.Save();
                        sconsole.LOG("STEAM: Downgrade should have been successful");
                        MessageBox.Show("STEAM: Downgrade should have been successful");
                    }
                }
                else
                {
                    sconsole.LOG("Found Rockstar Version");
                    Thread.Sleep(200);
                    string s = Directory.GetCurrentDirectory();
                    if (!File.Exists(GTAPATH.Text + @"\GTA5.exe") ||
                        !File.Exists(GTAPATH.Text + @"\GTAVLauncher.exe") ||
                        !File.Exists(GTAPATH.Text + @"\update\update.rpf"))
                    {
                        sconsole.LOG("sry one of these files were not found\nGTA5.exe\nPlayGTAV.exe\nGTAVLauncher.exe\nupdate.rpf");
                        MessageBox.Show("Please look at the LOG as we couldnt find a specific file\nYou should probably verify your Game!");
                    }
                    else
                    {
                        sconsole.LOG("Backing Up Files");
                        File.Copy(GTAPATH.Text + @"\GTA5.exe", s + @"\Backup\Rockstar\GTA5.exe", true);
                        Thread.Sleep(300);
                        File.Copy(GTAPATH.Text + @"\GTAVLauncher.exe", s + @"\Backup\Rockstar\GTAVLauncher.exe", true);
                        Thread.Sleep(300);
                        File.Copy(GTAPATH.Text + @"\update\update.rpf", s + @"\Backup\Rockstar\update.rpf", true);
                        Thread.Sleep(300);
                        Process p = new Process();
                        //sconsole.LOG("Uninstalling Social Club...");
                        RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\WOW6432Node\Rockstar Games", true);
                        sconsole.LOG("Deleting Social Club REG KEY");
                        key.DeleteSubKey("Rockstar Games Social Club");

                        key.OpenSubKey("Version", RegistryKeyPermissionCheck.ReadWriteSubTree);
                        key.SetValue("Version", "1.0.0.0", RegistryValueKind.String);
                        key.Close();

                        p.StartInfo.FileName = s + @"\common\uninstall.exe";
                        p.Start();
                        Thread.Sleep(1000);
                        sconsole.LOG("Rockstar Games Launcher Uninstaller Started");
                        while (!p.HasExited)
                        {
                            if (p.HasExited)
                            {
                                sconsole.LOG("Rockstar Games Launcher probably has been sucessfully uninstalled");
                                break;
                            }
                            else
                            {
                                Thread.Sleep(500);
                            }
                        }
                        p.StartInfo.FileName = s + @"\Rockstar\Social-Club-v1.1.6.0-Setup.exe";
                        p.Start();
                        Thread.Sleep(1000);
                        sconsole.LOG("Social Club Installer Started");
                        while (!p.HasExited)
                        {
                            if (p.HasExited)
                            {
                                sconsole.LOG("Social Club has probably been installed");
                                break;
                            }
                            else
                            {
                                Thread.Sleep(500);
                            }
                        }
                        Thread.Sleep(500);
                        sconsole.LOG("ROCKSTAR: Placing 1.27 patch files into GTA Directory");
                        if (File.Exists(GTAPATH.Text + "GTA5.exe"))
                        {
                            File.Delete(GTAPATH.Text + "GTA5.exe");
                        }
                        if (File.Exists(GTAPATH.Text + "GTAVLauncher.exe"))
                        {
                            File.Delete(GTAPATH.Text + "GTAVLauncher.exe");
                        }
                        if (File.Exists(GTAPATH.Text + "x64a.rpf"))
                        {
                            File.Delete(GTAPATH.Text + "x64a.rpf");
                        }
                        if (File.Exists(GTAPATH.Text + @"\update\update.rpf"))
                        {
                            File.Delete(GTAPATH.Text + @"\update\update.rpf");
                        }
                        File.Copy(s + @"\Rockstar\GTA5.exe", GTAPATH.Text + "GTA5.exe", true);
                        File.Copy(s + @"\Rockstar\GTAVLauncher.exe", GTAPATH.Text + "GTAVLauncher.exe", true);
                        File.Copy(s + @"\Rockstar\x64a.rpf", GTAPATH.Text + "x64a.rpf", true);
                        if (File.Exists(GTAPATH.Text + "GFSDK_ShadowLib.win64.dll"))
                        {
                            File.Delete(GTAPATH.Text + "GFSDK_ShadowLib.win64.dll");
                        }
                        File.Copy(s + @"\Rockstar\GFSDK_ShadowLib.win64.dll", GTAPATH.Text + "GFSDK_ShadowLib.win64.dll", true);

                        File.Copy(s + @"\Common\update.rpf", GTAPATH.Text + @"\update\update.rpf", true);
                        sconsole.LOG("Creating Shortcut");
                        var wsh = new IWshRuntimeLibrary.IWshShell_Class();
                        IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(
                            GTAPATH.Text + "\\GTAVLauncher.lnk") as IWshRuntimeLibrary.IWshShortcut;
                        shortcut.Arguments  = "-scOfflineOnly";
                        shortcut.TargetPath = GTAPATH.Text + "GTAVLauncher.exe";
                        shortcut.Save();
                        sconsole.LOG("ROCKSTAR: Downgrade should have been successful");
                        MessageBox.Show("ROCKSTAR: Downgrade should have been successful");
                    }
                }
            }
            else //if Messagebox input = no/closed do nothing and give an console error
            {
                sconsole.LOG("Messagebox Got A No Or Got Closed");
            }
        }
Example #11
0
        private void InitShortcuts()
        {
            string installDir = (string)Registry.GetValue(keyName, "installDir", "Not Exist");
            string packageDir = (string)Registry.GetValue(keyName, "packageDir", "Not Exist");
            string shortcutDir = (string)Registry.GetValue(keyName, "shortcutDir", "Not Exist");
            /*
            try
            {
                ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, policy) =>
                {
                    return true;
                };
            }
            catch (Exception ex)
            {
                eventLog1.WriteEntry(ex.Message);
            }//*/
            WebClient myWebClient = new WebClient();
            try
            {
                string serverDir = (string)Registry.GetValue(keyName, "serverDir", "Not Exist");
                myWebClient.DownloadFile(serverDir + "/packages.txt", packageDir + "\\packages.txt");
            }
            catch (Exception ex)
            {
                eventLog1.WriteEntry("Nastala chyba pri stahovani balicka " + ex.Message);
                return;
            }
            finally
            {
                if (myWebClient != null) myWebClient.Dispose();
            }

            string[] packList = File.ReadAllLines(packageDir + "\\packages.txt");
            string package = "";
            string path;
            string[] tmp;

            // pre kazdy balik spravime shortcut
            foreach (string line in packList)
            {
                //tmp = line.Split('~');
                tmp = line.Split(new string[] { "~~" }, StringSplitOptions.None);
                if (line[0] == 'p')
                {
                    package = tmp[1];
                    if (line[1] == 'a')
                    {
                        //tmp = line.Split(' ');
                        path = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + package + ".lnk";
                        var wsh = new IWshRuntimeLibrary.IWshShell_Class();
                        IWshRuntimeLibrary.IWshShortcut shortcut = wsh.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\" + package + ".lnk") as IWshRuntimeLibrary.IWshShortcut;
                        shortcut.Arguments = package;
                        shortcut.TargetPath = installDir;
                        shortcut.Save();
                    }
                }
                if (line[0] == 's')
                {
                    path = shortcutDir + "\\" + tmp[1] + ".lnk";
                    var wsh = new IWshRuntimeLibrary.IWshShell_Class();
                    IWshRuntimeLibrary.IWshShortcut shortcut =
                        wsh.CreateShortcut(shortcutDir + "\\" + tmp[1] + ".lnk")
                        as IWshRuntimeLibrary.IWshShortcut;
                    shortcut.Arguments = " \"" + package +  "\" \"" + tmp[2] + "\"";
                    shortcut.TargetPath = System.IO.Path.Combine(installDir, "UserApp.exe");
                    shortcut.Save();
                }
            }
        }