Example #1
0
        /// <summary>
        /// 起動に該当する設定用のパネルコントロールに関するクラスのインスタンスを生成する
        /// </summary>
        /// <param name="exeStartPanel">起動に該当する設定用のパネルコントロール</param>
        /// <param name="setting">プロパティグリッドコントロールに関連付けされている設定情報</param>
        /// <param name="propertyName">対象とする起動に該当する設定情報のプロパティ名</param>
        /// <returns>起動に該当する設定用のパネルコントロールに関するクラスのインスタンス</returns>
        public static SettingPanel CreateInstanceExeStart(
            Panel exeStartPanel, Setting setting, string propertyName)
        {
            return(new SettingPanel(
                       exeStartPanel,
                       () => GetSettingPropertyValue <string>(setting, propertyName),
                       (property) => Path.GetFileName(property),
                       (property) => CheckExeStartProperty(property),
                       (property) => StartProcess.Start(property)));

            // 起動に該当する設定情報のプロパティの設定値についてチェックを行う
            // 引数1:起動に該当する設定情報のプロパティ
            // 戻り値:チェック結果のプロパティ設定のステータス
            PropertySettingStatus CheckExeStartProperty(string property)
            {
                // 起動対象のパスが存在しない場合、未設定を返却
                if (string.IsNullOrWhiteSpace(property))
                {
                    return(PropertySettingStatus.NotSet);
                }

                // 起動対象のパスのファイル又はフォルダが存在するかチェック
                // 起動対象のパスのファイル又はフォルダが存在しない場合、エラーを返却
                // (ショートカットの場合は拡張子「.lnk」を付与して判定する)
                if (!File.Exists(property) &&
                    !Directory.Exists(property) &&
                    !File.Exists(property + ".lnk"))
                {
                    return(PropertySettingStatus.Error);
                }

                // 上記チェックがOKの場合、正常を返却
                return(PropertySettingStatus.Ok);
            }
        }
Example #2
0
        public Boolean startConnection(out String errorMessage)
        {
            errorMessage = String.Empty;

            //Check if application path exist with resolved OS variables
            if (File.Exists(Environment.ExpandEnvironmentVariables(this.application.path)))
            {
                //Overwrite application options if set in keepass entry
                if (this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField).Length > 0)
                {
                    this.customConnectionOptions = this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField);
                }

                //Create a thread to allow non gui blocking sleeps
                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true; //Background threads will stop automatically on program close

                    //Fill placeholders in options and start programm
                    StartProcess.Start(fillPlaceholders(this.application.path), fillPlaceholders(this.customConnectionOptions));
                }).Start();


                return(true);
            }
            else
            {
                errorMessage = ("Application '" + application.path + "' not found!");
                return(false);
            }
        }
        public Boolean startConnection(out String errorMessage)
        {
            errorMessage = String.Empty;

            //Check if application path exist
            if (File.Exists(Environment.ExpandEnvironmentVariables(RDPConnectionItem.pathToRemoteDesktop)))
            {
                if (File.Exists(Environment.ExpandEnvironmentVariables(RDPConnectionItem.pathToCMDKey)))
                {
                    //Overwrite the default rdp parameter if set in keepass entry
                    if (this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField).Length > 0)
                    {
                        this.rdpCustomParameter = this.keepassEntry.Strings.ReadSafe(this.plugin.settings.connectionOptionsField);
                    }

                    //Create a thread to allow non gui blocking sleeps
                    new Thread(() =>
                    {
                        Thread.CurrentThread.IsBackground = true; //Background threads will stop automatically on program close

                        //Fill placeholders in options and start programm (cmdkey sets the rdp credentials)
                        StartProcess.Start(RDPConnectionItem.pathToCMDKey, fillPlaceholders(buildAddingCmdkeyParameter()));

                        //Wait before RDP start
                        Thread.Sleep(TimeSpan.FromMilliseconds(500));

                        //Fill placeholders in options and start remote desktop with thread delay
                        StartProcess.Start(RDPConnectionItem.pathToRemoteDesktop, fillPlaceholders(buildRDPParameter()));

                        //Wait before credential remove
                        Thread.Sleep(TimeSpan.FromMilliseconds(5000));

                        //Fill placeholders in options and start programm with thread delay(cmdkey removes the previous set rdp credentials)
                        StartProcess.Start(RDPConnectionItem.pathToCMDKey, fillPlaceholders(buildRemovingCmdkeyParameter()));
                    }).Start();

                    return(true);
                }
                else
                {
                    errorMessage = ("Application '" + RDPConnectionItem.pathToCMDKey + "' not found!");
                    return(false);
                }
            }
            else
            {
                errorMessage = ("Application '" + RDPConnectionItem.pathToRemoteDesktop + "' not found!");
                return(false);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            var notAdminUsername = new StartProcess("calc.exe");

            notAdminUsername.Start();

            var json = UnsecureSerializer <StartProcess> .Serialize(notAdminUsername);

            var tamperedJson = json.Replace("calc.exe", "Virus.exe");

            var adminUsername = UnsecureSerializer <StartProcess> .Deserialize(tamperedJson);

            adminUsername.Start();
        }