Ejemplo n.º 1
0
        // -------------------------------------------------------------

        /** [STATIC]
         * Erstellt alle nötigen VBS Dateien im Temp ordner
         */
        private static void CreateTempVBSFiles(  )
        {
            #if (LOGLEVEL_DEBUG)
            Logging.Trace(KLASSE + ".CreateTempVBSFiles (  )");
            #endif

            // -------------------------------

            string TempPath_string = Shortcuts.tempPath_string;
            bool   PathNotExists   = !Directory.Exists(TempPath_string);

            if (PathNotExists)
            {
                Directory.CreateDirectory(TempPath_string);
            }

            Shortcuts.CreateVBSFile(TempPath_string + VBSFileNames.GetTargetPath, Shortcuts.WSCRIPT + Shortcuts.TARGETPATH);
            Shortcuts.CreateVBSFile(TempPath_string + VBSFileNames.GetArguments, Shortcuts.WSCRIPT + Shortcuts.ARGUMENTS);
            Shortcuts.CreateVBSFile(TempPath_string + VBSFileNames.GetIconLocation, Shortcuts.WSCRIPT + Shortcuts.ICONLOCATION);
            Shortcuts.CreateVBSFile(TempPath_string + VBSFileNames.GetWorkingDirectory, Shortcuts.WSCRIPT + Shortcuts.WORKINGDIRECTORY);
            Shortcuts.CreateVBSFile(TempPath_string + VBSFileNames.GetHotKey, Shortcuts.WSCRIPT + Shortcuts.HOTKEY);
            Shortcuts.CreateVBSFile(TempPath_string + VBSFileNames.GetWindowSytle, Shortcuts.WSCRIPT + Shortcuts.WINDOWSTYLE);

            Shortcuts.CreateVBS_SETValue(TempPath_string + VBSFileNames.SetTargetPath, Shortcuts.TARGETPATH);
            Shortcuts.CreateVBS_SETValue(TempPath_string + VBSFileNames.SetArguments, Shortcuts.ARGUMENTS);
            Shortcuts.CreateVBS_SETValue(TempPath_string + VBSFileNames.SetIconLocation, Shortcuts.ICONLOCATION);
            Shortcuts.CreateVBS_SETValue(TempPath_string + VBSFileNames.SetWorkingDirectory, Shortcuts.WORKINGDIRECTORY);
            Shortcuts.CreateVBS_SETValue(TempPath_string + VBSFileNames.SetHotKey, Shortcuts.HOTKEY);
            Shortcuts.CreateVBS_SETValue(TempPath_string + VBSFileNames.SetWindowStyle, Shortcuts.WINDOWSTYLE);

            // -------------------------------

            TempPath_string = null;
        }
Ejemplo n.º 2
0
        // -------------------------------------------------------------

        /** [STATIC]
         * Setzt den TargetPath einer Verknüpfung
         *
         * @param[in] _Path_string       (string) Der Pfad zu der Verknüpfung
         * @param[in] _TargetPath_string (string) Der TargetPath
         */
        private static bool SetLNKValue(string _Path_string, string _TargetPath_string, string _ValueFile)
        {
            #if (LOGLEVEL_DEBUG)
            string methodeName = KLASSE + ".SetTargetPath ( string _Path_string )";
            Logging.Trace(methodeName);
            Logging.Debug(methodeName, "_Path_string", _Path_string);
            #endif

            if (string.IsNullOrEmpty(_TargetPath_string))
            {
                return(false);
            }

            // -------------------------------

            string Arguments_string = string.Format("\"{0}\" \"{1}\"", _Path_string, _TargetPath_string.Replace("\"", "\\'"));
            string TempPath_string  = tempPath_string + _ValueFile;

            Shortcuts.RunVBSFile(TempPath_string, Arguments_string);

            // -------------------------------

            _Path_string       = null;
            _TargetPath_string = null;
            Arguments_string   = null;
            TempPath_string    = null;

            return(true);
        }
Ejemplo n.º 3
0
        // -------------------------------------------------------------

        /**
         * Konstuktor dieser Klasse
         */
        public Shortcuts(  )
        {
            #if (LOGLEVEL_DEBUG)
            string methodeName = string.Format("new {0} (  ) - Konstruktor", KLASSE);
            Logging.Trace(methodeName);
            #endif

            // -------------------------------

            this.hasAdminPrivileg_bool = false;

            Shortcuts.CreateTempVBSFiles(  );
        }
Ejemplo n.º 4
0
        // -------------------------------------------------------------

        /** [STATIC]
         * Legt eine VBS Datei an, die den TargetPath aus einer Verknüpgunh festlegt
         *
         * @param[in] _FilePath_string (string) Der Pfad wo die VBS Datei liegen soll
         */
        private static void CreateVBS_SETValue(string _FilePath_string, string _Value)
        {
            #if (LOGLEVEL_DEBUG)
            string methodeName = KLASSE + ".CreateVBS_SETValue ( string _FilePath_string, string _Value )";
            Logging.Trace(methodeName);
            Logging.Debug(methodeName, "_FilePath_string", _FilePath_string);
            Logging.Debug(methodeName, "_Value", _Value);
            #endif

            // -------------------------------

            string VBS_Content_string = CreateVBS_ContentSave(_Value);

            Shortcuts.CreateVBSFile(_FilePath_string, VBS_Content_string);

            // -------------------------------

            _Value             = null;
            _FilePath_string   = null;
            VBS_Content_string = null;
        }
Ejemplo n.º 5
0
        // -------------------------------------------------------------

        /** [STATIC]
         * Liest eine bereits vorhandene Verknüpfung ein
         *
         * @param[in] _Path_string (string) Der Pfad von wo die Verknüpfung eingelesen werden soll
         *
         * @return (bool) Wenn true zurück gegeben wird gab es keine probleme. Bei false konnte keine Datei eingelesen werden
         */
        public bool Read(string _Path_string)
        {
            #if (LOGLEVEL_DEBUG)
            string methodeName = KLASSE + ".Read ( string _Path_string )";
            Logging.Trace(methodeName);
            Logging.Debug(methodeName, "_Path_string", _Path_string);
            #endif

            if (string.IsNullOrEmpty(_Path_string))
            {
                return(false);
            }
            if (!File.Exists(_Path_string))
            {
                return(false);
            }

            // -------------------------------

            this.TargetPath = Shortcuts.GetLNKValue(_Path_string, VBSFileNames.GetTargetPath);

            this.Arguments = Shortcuts.GetLNKValue(_Path_string, VBSFileNames.GetArguments);

            this.IconLocation = Shortcuts.GetLNKValue(_Path_string, VBSFileNames.GetIconLocation);

            this.WorkingDirectory = Shortcuts.GetLNKValue(_Path_string, VBSFileNames.GetWorkingDirectory);

            this.HotKey = Shortcuts.GetLNKValue(_Path_string, VBSFileNames.GetHotKey);

            this.WindowStyle = Shortcuts.GetLNKValue(_Path_string, VBSFileNames.GetWindowSytle);

            this.hasAdminPrivileg_bool = false;

            // -------------------------------

            _Path_string = null;

            return(true);
        }
Ejemplo n.º 6
0
        // -------------------------------------------------------------

        #endregion ctor

        // -------------------------------------------------------------

        #region methods

        // -------------------------------------------------------------

        /**
         * Überschreibt eine vorhandene Verknüpfung mit neu gestzten werten, wenn keine existiert wird eine angelegt
         *
         * @param[in] _Path_string (string)
         *
         * @return (bool) Wenn true zurück gegeben wird gab es keine probleme. Bei false konnte keine Datei angelegt werden oder geupdatet werden
         */
        public bool Update(string _Path_string)
        {
            #if (LOGLEVEL_DEBUG)
            string methodeName = KLASSE + ".Update ( string _Path_string )";
            Logging.Trace(methodeName);
            Logging.Debug(methodeName, "_Path_string", _Path_string);
            #endif

            if (string.IsNullOrEmpty(_Path_string))
            {
                return(false);
            }

            // -------------------------------

            Shortcuts.SetLNKValue(_Path_string, this.TargetPath, VBSFileNames.SetTargetPath);

            Shortcuts.SetLNKValue(_Path_string, this.Arguments, VBSFileNames.SetArguments);

            Shortcuts.SetLNKValue(_Path_string, this.IconLocation, VBSFileNames.SetIconLocation);

            Shortcuts.SetLNKValue(_Path_string, this.WorkingDirectory, VBSFileNames.SetWorkingDirectory);

            Shortcuts.SetLNKValue(_Path_string, this.HotKey, VBSFileNames.SetHotKey);

            Shortcuts.SetLNKValue(_Path_string, this.WindowStyle, VBSFileNames.SetWindowStyle);

            if (this.hasAdminPrivileg_bool)
            {
                Shortcuts.WriteAdminPrivilieg(_Path_string);
            }

            // -------------------------------

            _Path_string = null;

            return(File.Exists(_Path_string));
        }
Ejemplo n.º 7
0
        // -------------------------------------------------------------

        /** [STATIC]
         * Gibt den TargetPath einer Verknüpfung wieder
         *
         * @param[in] _Path_string (string) Der Pfad zu der Verknüpfung
         *
         * @return (string) Der TargetPath
         */
        private static string GetLNKValue(string _Path_string, string _ValueFile)
        {
            #if (LOGLEVEL_DEBUG)
            string methodeName = KLASSE + ".GetTargetPath ( string _Path_string )";
            Logging.Trace(methodeName);
            Logging.Debug(methodeName, "_Path_string", _Path_string);
            #endif

            // -------------------------------

            string result_string    = string.Empty;
            string Arguments_string = string.Format("\"{0}\"", _Path_string);
            string TempPath_string  = tempPath_string + _ValueFile;

            result_string = Shortcuts.RunVBSFile(TempPath_string, Arguments_string);

            // -------------------------------

            _Path_string     = null;
            Arguments_string = null;
            TempPath_string  = null;

            return(result_string);
        }