示例#1
0
        public static void CreateShortcut()
        {
            var lnkFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"{nameof(Kebler)}.lnk");

            Shortcut.Create(lnkFileName, ConstStrings.KeblerExepath,
                            ConstStrings.KeblerAppFolderPath, ConstStrings.KeblerAppFolderPath, "", null, ConstStrings.KeblerExepath);
        }
示例#2
0
        private void CopyTorchFiles()
        {
            var torchDir = Path.Combine(_basePath, "bin-torch");

            if (Directory.Exists(torchDir))
            {
                Directory.Delete(torchDir, true);
            }

            Directory.CreateDirectory(torchDir);

            foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory()))
            {
                var info = new FileInfo(file);

                if (info.Extension == ".exe" || info.Extension == ".dll")
                {
                    var dest = Path.Combine(torchDir, info.Name);
                    File.Copy(file, dest);
                }
            }

            const string domainOptions = "..\\\nbin-torch;DedicatedServer64";

            File.WriteAllText(Path.Combine(torchDir, "domain"), domainOptions);

            Shortcut.Create(
                Path.Combine(_basePath, "Torch.lnk"),
                Path.Combine(torchDir, "Torch.exe"),
                "--load Torch.SpaceEngineers.dll",
                torchDir,
                "Launch Torch",
                string.Empty,
                string.Empty);
        }
示例#3
0
 /// <summary>
 /// ショートカットを作成します。
 /// </summary>
 public void Create()
 {
     if (!this.IsExists)
     {
         Shortcut.Create(this.path);
     }
 }
示例#4
0
        public void CreateShortcut()
        {
            var lnkFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Kebler.lnk");

            Shortcut.Create(lnkFileName, ConstStrings.KeblerExepath,
                            null, null, nameof(Kebler), null, null);
        }
        private void tsmiAutoStart_Click(object sender, EventArgs e)
        {
            try
            {
                if (!tsmiAutoStart.Checked && !File.Exists(startupLnkPath)) // Create shortcut
                {
                    Shortcut shortcut = new Shortcut
                    {
                        Address      = startupLnkPath,
                        Description  = "An auto-start shortcut for Lock Keys Indicator",
                        IconLocation = Assembly.GetEntryAssembly().Location,
                        Target       = Assembly.GetEntryAssembly().Location,
                        WorkingDir   = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location),
                    };
                    shortcut.Create();
                }
                else if (tsmiAutoStart.Checked && File.Exists(startupLnkPath))
                {
                    File.Delete(startupLnkPath);
                }                                                    // Remove shortcut

                tsmiAutoStart.Checked = File.Exists(startupLnkPath); // Finally change Checked status (if all goes well)
            }
            catch { }
        }
示例#6
0
        static void Main()
        {
            try
            {
                BaseVariable.InitXmlVar();//初始化基础变量
                if (!File.Exists(BaseVariable.XmlFilePath))
                {
                    throw new Exception("Config.xml配置文件不存在,请检查");
                }
                XmlHelper xml = new XmlHelper();
                BaseVariable.RequestURL = xml.SelectValue("/Root/Server/APIURL");
                string modelVaild = xml.SelectValue("/Root/Sys/ModelVaild");
                if (modelVaild.Trim().Equals("1"))
                {
                    string c = BaseVariable.APPRootPath + "config.dat";
                    if (!File.Exists(BaseVariable.XmlFilePath))
                    {
                        throw new Exception("config.dat系统文件不存在,请检查");
                    }

                    SystemIdentity info = SystemIdentity.GetFromFile(c);

                    if (info.GetDeviceModel() != "CK3X")
                    {
                        throw new Exception("设备版本不兼容!!!");
                    }
                }

                string appName = Assembly.GetExecutingAssembly().GetName().Name;
                if (!MutexHelper.IsApplicationOnRun(appName))
                {
                    #region 创建快捷方式
                    Shortcut sc = new Shortcut(Assembly.GetExecutingAssembly(), "鸿泰集成防错系统");
                    if (!sc.IsExist())
                    {
                        sc.Create();
                    }
                    #endregion

                    TaskBarHelper.ShowTaskBar(false);
                    Application.Run(new FrmLogin());
                    Application.Exit();
                }
                else
                {
                    MessageBox.Show("系统正在运行!");//如果该程序已经运行则返回,避免程序重复运行
                    Application.Exit();
                    return;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
            }
            finally
            {
                TaskBarHelper.ShowTaskBar(true);
            }
        }
示例#7
0
    public void TestCreate()
    {
        using var tempDir = new TemporaryDirectory("0install-unit-test");
        string path = Path.Combine(tempDir, "shortcut.lnk");

        Shortcut.Create(path, targetPath: "xyz");
        File.Exists(path).Should().BeTrue();
    }
        public void Execute(object parameter)
        {
            if (!(_workspace.CurrentItem is FileItem fileItem))
            {
                return;
            }
            var favorites = Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
            var fileName  = Path.Combine(favorites, fileItem.Name + ".lnk");

            Shortcut.Create(fileName, fileItem.Path, null, null, "Shortcut to " + fileItem.Name, null);
        }
示例#9
0
    public void TestCreate()
    {
        using var tempDir = new TemporaryDirectory("0install-unit-test");
        string path = Path.Combine(tempDir, "shortcut.lnk");

        Shortcut.Create(path, targetPath: "abc", arguments: "xyz");

        var shortcut = ShellLink.Shortcut.ReadFromFile(path);

        shortcut.ExtraData.EnvironmentVariableDataBlock.TargetUnicode.Should().Be("abc");
        shortcut.StringData.CommandLineArguments.Should().Be("xyz");
    }
示例#10
0
        public static IWshShortcut Create(string name, string description, string iconLocation, string targetPath, string arguments)
        {
            string   linkAddress = CreateDesktopLinkAddress(name);
            Shortcut shortcut    = Shortcut.Create(linkAddress);

            shortcut.Description  = description;
            shortcut.Arguments    = arguments;
            shortcut.TargetPath   = targetPath;
            shortcut.IconLocation = iconLocation;
            shortcut.Save();
            return(shortcut);
        }
示例#11
0
        private void DesktopIntegrationApply()
        {
            if (WindowsUtils.IsWindows)
            {
                Handler.RunTask(new SimpleTask(Resources.DesktopIntegrationApply, () =>
                {
                    Shortcut.Create(
                        path: Shortcut.GetStartMenuPath("", "Zero Install", MachineWide),
                        targetPath: Path.Combine(TargetDir, "ZeroInstall.exe"));

                    PathEnv.AddDir(TargetDir, MachineWide);
                }));
            }
        }
    /// <summary>
    /// Add executable file of this app to registry startup path:
    /// 'LocalMachine\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
    /// </summary>
    /// <param name="targetEveryone">Run as administrator</param>
    public static void AddToStartup(Boolean targetEveryone)
    {
        try
        {
            using (RegistryKey main = (targetEveryone & IsAdmin() ? Registry.LocalMachine : Registry.CurrentUser))
            {
                using (RegistryKey key = main.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
                {
                    String fileName = Path.GetFileNameWithoutExtension(Application.ExecutablePath);

                    if (key.GetValue(fileName) == null)
                    {
                        key.SetValue(fileName, Application.ExecutablePath);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            // report exception ...

            //
            // Copy Shortcut To CommonStartUp or StartUp
            //
            try
            {
                Environment.SpecialFolder folder = ((targetEveryone && IsWindowsVistaOrHigher()) ? Environment.SpecialFolder.CommonStartup : Environment.SpecialFolder.Startup);
                String fileDestination           = Path.Combine(Environment.GetFolderPath(folder), Path.GetFileNameWithoutExtension(Application.ExecutablePath)) + ".lnk";

                if (!File.Exists(fileDestination))
                {
                    Shortcut.Create(fileDestination, Application.ExecutablePath, null, null, "description...", null, null);
                }
            }
            catch (Exception exp)
            {
                // report exception ...
            }
        }
    }
示例#13
0
    private void DesktopIntegrationApply(long size)
    {
        Handler.RunTask(new SimpleTask(Resources.DesktopIntegrationApply, () =>
        {
            UninstallEntry.Register(
                UninstallID,
                new[] { Path.Combine(TargetDir, "0install-win.exe"), Self.Name, Self.Remove.Name },
                "Zero Install",
                new("https://0install.net/"),
                iconPath: Path.Combine(TargetDir, "ZeroInstall.exe"),
                AppInfo.Current.Version,
                size,
                MachineWide);

            RegistryUtils.SetSoftwareString(@"Microsoft\PackageManagement", "ZeroInstall", Path.Combine(TargetDir, "ZeroInstall.OneGet.dll"), MachineWide);

            PathEnv.AddDir(TargetDir, MachineWide);

            Shortcut.Create(
                path: Shortcut.GetStartMenuPath("", "Zero Install", MachineWide),
                targetPath: Path.Combine(TargetDir, "ZeroInstall.exe"),
                appId: "ZeroInstall");
        }));
示例#14
0
 public void CanDealWithWeirdCharacters()
 {
     Shortcut.Create(".lnk", "äöü", "", "", "", "", "");
 }
示例#15
0
 public void CantDealWithNull()
 {
     Assert.Throws <ArgumentException>(() => Shortcut.Create(".lnk", null, "", "", "", "", ""));
 }
示例#16
0
 public void CanDealWithLongFiles()
 {
     Shortcut.Create(".lnk", Path.Combine(Path.GetTempPath(), string.Join("_", new string[500])), "", "", "", "", "");
 }
示例#17
0
 public void CanDealWithEmptyFiles()
 {
     Shortcut.Create(".lnk", "", "", "", "", "", "");
 }