Esempio n. 1
0
        //



        /// <summary>
        /// Gets the session id of user console session
        /// </summary>
        /// <returns>Session id of user console session</returns>
        public static int GetConsoleSessionId()
        {
            ExecutionServiceClient executionServiceClient = ExecutionServiceClient.Connect();

            if (executionServiceClient != null)
            {
                ExecutionServiceClientConnection connection = executionServiceClient.BeginConnection(RuntimeConnectionName, true);
                return(connection.UserSessionGetConsoleSessionId());
            }
            else
            {
                throw new InvalidOperationException("Can't get a connection to ExecutionServiceClient");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Connects to user session specified by sessionId
        /// </summary>
        /// <param name="sessionId">Session Id to disconnect from</param>
        public static void ConnectToUserSession(int sessionId)
        {
            ExecutionServiceClient executionServiceClient = ExecutionServiceClient.Connect();

            if (executionServiceClient != null)
            {
                ExecutionServiceClientConnection connection = executionServiceClient.BeginConnection(RuntimeConnectionName, true);
                connection.UserSessionConnect(sessionId, "Console");
            }
            else
            {
                throw new InvalidOperationException("Can't get a connection to ExecutionServiceClient");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Sets a registry value, using the same syntax as Registry.SetValue
        /// </summary>
        /// <param name="keyName">name of the registry key including hive</param>
        /// <param name="valueName">name of the key value, string.empty = default</param>
        /// <param name="value">registry key value, null will delete the registry value</param>
        public static void SetRegistryValue(string keyName, string valueName, object value)
        {
            //Connect to the exectution service
            ExecutionServiceClient executionServiceClient = ExecutionServiceClient.Connect();

            if (executionServiceClient != null)
            {
                ExecutionServiceClientConnection connection = executionServiceClient.BeginConnection(RuntimeConnectionName, true);
                connection.SetRegistryValue(keyName, valueName, value);
            }
            else
            {
                //The Execution Service is not istalled so do this in process
                //NOTE: this wont work for HKEY_LM keys under LUA without ExecutionService
                if (valueName != null && !Object.Equals(value, null))
                {
                    Registry.SetValue(keyName, valueName, value);
                }
                else
                {
                    RegistryState.DeleteRegistryValue(keyName, valueName);
                }
            }
        }