How to modify services through batch or script files?

Min Wang 0 Reputation points
2023-06-27T08:39:26.09+00:00

As shown in the figure, modify the Windows Update option in the service, select the startup type as "Disabled", and change the "Restart Service" to "No Action". Can I quickly execute it by editing the reg file or bat file? Is there a document that explains the relevant commands and usage?

图片

图片

图片

Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Limitless Technology 44,746 Reputation points
    2023-06-28T12:27:03.3466667+00:00

    Hello Min,

    Thank you for your question and for reaching out with your question today.

    Yes, you can modify services through batch or script files using command-line tools provided by Windows. Here's an overview of the process and some relevant commands:

    1. Open a text editor and create a new batch file with a .bat extension, or a script file with a .cmd or .ps1 extension for PowerShell scripts.
    2. To modify a service, you can use the sc command (Service Control Manager) or PowerShell cmdlets like Set-Service or Get-Service.
    3. Here's an example of how to disable the Windows Update service using the sc command in a batch file:
    
    @echo off
    
    sc config wuauserv start= disabled
    
    

    This command sets the startup type of the Windows Update service (wuauserv) to "Disabled".

    1. If you prefer using PowerShell, you can use the Set-Service cmdlet to achieve the same result:
    
    Set-Service -Name wuauserv -StartupType Disabled
    
    
    1. To change the "Restart Service" option, you need to modify the service recovery settings. This can be done using the sc command with the failure parameter. Here's an example:
    
    @echo off
    
    sc failure wuauserv actions= none
    
    

    This command sets the "Restart Service" option for the Windows Update service to "No Action".

    1. Save the batch or script file with an appropriate name, like "modify_service.bat" or "modify_service.ps1".
    2. Run the batch or script file with administrative privileges by right-clicking on it and selecting "Run as administrator". This is necessary because modifying services requires administrative privileges.

    Please note that modifying services should be done with caution as it can have significant impacts on the system. Make sure you understand the consequences of modifying a particular service before making any changes.

    For more information and detailed documentation on commands and usage, you can refer to the official Microsoft documentation:

    Remember to always test any changes in a controlled environment before applying them to production systems.

    I used AI provided by ChatGPT to formulate part of this response. I have verified that the information is accurate before sharing it with you.

    If the reply was helpful, please don’t forget to upvote or accept as answer.


  2. Min Wang 0 Reputation points
    2023-07-04T06:42:50.4633333+00:00

    Run the file in administrator mode,Did not change 'Restart Service' to 'No Action':

    @echo off

    sc config wuauserv start= disabled

    sc failure wuauserv actions= none

    EXIT

    图片

    0 comments No comments

  3. Min Wang 0 Reputation points
    2023-07-04T06:43:44.12+00:00

    Run the file in administrator mode,Did not change 'Restart Service' to 'No Action':

    @echo off

    sc config wuauserv start= disabled

    sc failure wuauserv actions= none

    EXIT

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.