Example #1
0
        /// <summary>
        /// Modifies a service
        /// </summary>
        /// <param name="displayName">The display name of the service. This string has a maximum length of 256 characters. The name is case-preserved in the service control manager. DisplayName comparisons are always case-insensitive. </param>
        /// <param name="pathName">The fully-qualified path to the executable file that implements the service, for example, "\SystemRoot\System32\drivers\afd.sys".</param>
        /// <param name="serviceType">The type of services provided to processes that call them.</param>
        /// <param name="errorControl">Severity of the error if this service fails to start during startup. The value indicates the action taken by the startup program if failure occurs. All errors are logged by the system.</param>
        /// <param name="startMode">Start mode of the Windows base service.</param>
        /// <param name="desktopInteract">If true, the service can create or communicate with a window on the desktop.</param>
        /// <param name="startName">Account name the service runs under. Depending on the service type, the account name may be in the form of DomainName\Username or .\Username. The service process will be logged using one of these two forms when it runs. If the account belongs to the built-in domain, .\Username can be specified. If NULL is specified, the service will be logged on as the LocalSystem account. For kernel or system-level drivers, StartName contains the driver object name (that is, \FileSystem\Rdr or \Driver\Xns) that the input and output (I/O) system uses to load the device driver. If NULL is specified, the driver runs with a default object name created by the I/O system based on the service name, for example, "DWDOM\Admin".   You also can use the User Principal Name (UPN) format to specify the StartName, for example, Username@DomainName.</param>
        /// <param name="startPassword">Password to the account name specified by the StartName parameter. Specify NULL if you are not changing the password. Specify an empty string if the service has no password.  Note  When changing a service from a local system to a network, or from a network to a local system, StartPassword must be an empty string ("") and not NULL. </param>
        /// <param name="loadOrderGroup">Group name that it is associated with. Load order groups are contained in the system registry, and determine the sequence in which services are loaded into the operating system. If the pointer is NULL, or if it points to an empty string, the service does not belong to a group. Dependencies between groups should be listed in the LoadOrderGroupDependencies parameter. Services in the load-ordering group list are started first, followed by services in groups not in the load-ordering group list, followed by services that do not belong to a group. The system registry has a list of load ordering groups located at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ServiceGroupOrder. </param>
        /// <param name="loadOrderGroupDependencies">List of load-ordering groups that must start before this service starts. The array is doubly null-terminated. If the pointer is NULL, or if it points to an empty string, the service has no dependencies. Group names must be prefixed by the SC_GROUP_IDENTIFIER (defined in the Winsvc.h file) character to differentiate them from service names because services and service groups share the same namespace. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all of the members of the group.</param>
        /// <param name="serviceDependencies">List that contains the names of services that must start before this service starts. The array is doubly NULL-terminated. If the pointer is NULL, or if it points to an empty string, the service has no dependencies. Dependency on a service indicates that this service can run only if the service it depends on is running.</param>
        /// <returns></returns>
        public ServiceManager.MethodExecutionResultEnum Change(
            string displayName,
            string pathName,
            ServiceTypeEnum serviceType,
            ErrorControlEnum errorControl,
            StartModeEnum startMode,
            bool desktopInteract,
            string startName,
            string startPassword,
            string loadOrderGroup,
            string loadOrderGroupDependencies,
            string serviceDependencies
            )
        {
            throw new NotImplementedException("Not tested, out of scope");

            ManagementBaseObject inParams = m_mo.GetMethodParameters("Change");

            inParams["DisplayName"]                = displayName;
            inParams["PathName"]                   = pathName;
            inParams["ServiceType"]                = (UInt32)serviceType;
            inParams["ErrorControl"]               = (UInt32)errorControl;
            inParams["StartMode"]                  = Convert.ToString(startMode); //TODO: make sure it works...
            inParams["DesktopInteract"]            = desktopInteract;
            inParams["StartName"]                  = startName;
            inParams["StartPassword"]              = startPassword;
            inParams["LoadOrderGroup"]             = loadOrderGroup;
            inParams["LoadOrderGroupDependencies"] = loadOrderGroupDependencies;
            inParams["ServiceDependencies"]        = serviceDependencies;

            return((ServiceManager.MethodExecutionResultEnum)Convert.ToUInt32(m_mo.InvokeMethod("Change", inParams, null)["ReturnValue"]));
        }
Example #2
0
        /// <summary>
        /// modifies the start mode of a service.
        /// </summary>
        /// <param name="startMode">Start mode of the Windows base service. </param>
        /// <returns></returns>
        public ServiceManager.MethodExecutionResultEnum ChangeStartMode(
            StartModeEnum startMode
            )
        {
            throw new NotImplementedException("Out of scope for project");

            ManagementBaseObject inParams = m_mo.GetMethodParameters("ChangeStartMode");

            inParams["StartMode"] = Convert.ToString(startMode); //TODO: make sure it works...

            return((ServiceManager.MethodExecutionResultEnum)Convert.ToUInt32(m_mo.InvokeMethod("ChangeStartMode", inParams, null)["ReturnValue"]));
        }
Example #3
0
        /// <summary>
        /// modifies the start mode of a service.
        /// </summary>
        /// <param name="startMode">Start mode of the Windows base service. </param>
        /// <returns></returns>
        public ServiceManager.MethodExecutionResultEnum ChangeStartMode(
                StartModeEnum startMode
            )
        {
            throw new NotImplementedException("Out of scope for project");

            ManagementBaseObject inParams = m_mo.GetMethodParameters("ChangeStartMode");

            inParams["StartMode"] = Convert.ToString(startMode); //TODO: make sure it works...

            return (ServiceManager.MethodExecutionResultEnum)Convert.ToUInt32(m_mo.InvokeMethod("ChangeStartMode", inParams, null)["ReturnValue"]);
        }
Example #4
0
        /// <summary>
        /// Modifies a service
        /// </summary>
        /// <param name="displayName">The display name of the service. This string has a maximum length of 256 characters. The name is case-preserved in the service control manager. DisplayName comparisons are always case-insensitive. </param>
        /// <param name="pathName">The fully-qualified path to the executable file that implements the service, for example, "\SystemRoot\System32\drivers\afd.sys".</param>
        /// <param name="serviceType">The type of services provided to processes that call them.</param>
        /// <param name="errorControl">Severity of the error if this service fails to start during startup. The value indicates the action taken by the startup program if failure occurs. All errors are logged by the system.</param>
        /// <param name="startMode">Start mode of the Windows base service.</param>
        /// <param name="desktopInteract">If true, the service can create or communicate with a window on the desktop.</param>
        /// <param name="startName">Account name the service runs under. Depending on the service type, the account name may be in the form of DomainName\Username or .\Username. The service process will be logged using one of these two forms when it runs. If the account belongs to the built-in domain, .\Username can be specified. If NULL is specified, the service will be logged on as the LocalSystem account. For kernel or system-level drivers, StartName contains the driver object name (that is, \FileSystem\Rdr or \Driver\Xns) that the input and output (I/O) system uses to load the device driver. If NULL is specified, the driver runs with a default object name created by the I/O system based on the service name, for example, "DWDOM\Admin".   You also can use the User Principal Name (UPN) format to specify the StartName, for example, Username@DomainName.</param>
        /// <param name="startPassword">Password to the account name specified by the StartName parameter. Specify NULL if you are not changing the password. Specify an empty string if the service has no password.  Note  When changing a service from a local system to a network, or from a network to a local system, StartPassword must be an empty string ("") and not NULL. </param>
        /// <param name="loadOrderGroup">Group name that it is associated with. Load order groups are contained in the system registry, and determine the sequence in which services are loaded into the operating system. If the pointer is NULL, or if it points to an empty string, the service does not belong to a group. Dependencies between groups should be listed in the LoadOrderGroupDependencies parameter. Services in the load-ordering group list are started first, followed by services in groups not in the load-ordering group list, followed by services that do not belong to a group. The system registry has a list of load ordering groups located at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ServiceGroupOrder. </param>
        /// <param name="loadOrderGroupDependencies">List of load-ordering groups that must start before this service starts. The array is doubly null-terminated. If the pointer is NULL, or if it points to an empty string, the service has no dependencies. Group names must be prefixed by the SC_GROUP_IDENTIFIER (defined in the Winsvc.h file) character to differentiate them from service names because services and service groups share the same namespace. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all of the members of the group.</param>
        /// <param name="serviceDependencies">List that contains the names of services that must start before this service starts. The array is doubly NULL-terminated. If the pointer is NULL, or if it points to an empty string, the service has no dependencies. Dependency on a service indicates that this service can run only if the service it depends on is running.</param>
        /// <returns></returns>
        public ServiceManager.MethodExecutionResultEnum Change(
                string displayName,
                string pathName,
                ServiceTypeEnum serviceType,
                ErrorControlEnum errorControl,
                StartModeEnum startMode,
                bool desktopInteract,
                string startName,
                string startPassword,
                string loadOrderGroup,
                string loadOrderGroupDependencies,
                string serviceDependencies
            )
        {
            throw new NotImplementedException("Not tested, out of scope");

            ManagementBaseObject inParams = m_mo.GetMethodParameters("Change");
            inParams["DisplayName"] = displayName;
            inParams["PathName"] = pathName;
            inParams["ServiceType"] = (UInt32)serviceType;
            inParams["ErrorControl"] = (UInt32)errorControl;
            inParams["StartMode"] = Convert.ToString(startMode); //TODO: make sure it works...
            inParams["DesktopInteract"] = desktopInteract;
            inParams["StartName"] = startName;
            inParams["StartPassword"] = startPassword;
            inParams["LoadOrderGroup"] = loadOrderGroup;
            inParams["LoadOrderGroupDependencies"] = loadOrderGroupDependencies;
            inParams["ServiceDependencies"] = serviceDependencies;

            return (ServiceManager.MethodExecutionResultEnum)Convert.ToUInt32(m_mo.InvokeMethod("Change", inParams, null)["ReturnValue"]);
        }