Stop Windows Services Before Patching
Log In or Register to download the BES file, and more.

0 Votes

Description

This task has four actions:

 Action 1: Compares the Running Services on a computer with a "WhiteList" file downloaded from the Root Server.  It then stops any running services that are NOT on that whitelist.

To use this action, a file with names of the Windows services that will not be stopped must be created and placed on the Root server.  The file name and location are user-defined in the action script under the parameters named:

whitelistfolder | whitelist

 

Action 2: Stops all services in a given list.

To use this action, a file with names of the Windows services that will be stopped must be created and placed on the Root server.  The file name and location are user-defined in the action script under the parameters named:

whitelistfolder | stoplist

 

Action 3: Stops only the specified service. 

To use this action, the operator must input the service name of a Windows service when prompted by the Task.

 

Action 4: Starts only the specified service. 

To use this action, the operator must input the service name of a Windows service when prompted by the Task.

 


Property Details

ID26928
StatusBeta - Preliminary testing ready for more
TitleStop Windows Services Before Patching
DomainPTCH
CategoryUtility
SourceInternal
Source SeverityInformational
Source Release Date4/15/2014 12:00:00 AM
KeywordsServices, Stop, Start, Patches, Patching, Windows
Is TaskTrue
Added by on 4/20/2022 8:39:49 PM
Last Modified by on 4/20/2022 8:39:49 PM
Counters 148 Views / 1 Download
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance


Actions

Action 1

Action Link Click here to stop ALL services NOT in the specified whitelist.
Script Type BigFix Action Script
///////////////////////////////////
// TO SET DIFFERENT FILE NAMES AND
// LOCATIONS CHANGE THE FOLLOWING
// PARAMETER VALUES
///////////////////////////////////

parameter "clientfolder" = "{(parent folder of client as string)}"
parameter "whitelistfolder" = "{(parameter "clientfolder" & "\ServicesWhitelist")}"
parameter "whitelist" = "{parameter "whitelistfolder" & "\ServicesWhitelist.txt"}"
parameter "runningservices" = "{parameter "whitelistfolder" & "\runningservices.txt"}"
parameter "blacklist" = "{parameter "whitelistfolder" & "\blacklist.txt"}"

// -END- PARAMETER DECLARATIONS



// Download the whiteList file from the Root Server
download now as ServicesWhitelist.txt http://ROOTSERVERNAME:52311/CustomDownloads/ServicesWhitelist/ServicesWhitelist.txt
pause while {not exists file "__Download\ServicesWhitelist.txt"}

// Check for the existence of the 'ServicesWhitelist' directory in the Client Folder on the target
// If the directory exists, just copy the file over, if not, create the folder and copy the file over
if {not exists folder (parameter "whitelistfolder")}
    dos mkdir "{parameter "whitelistfolder"}"
    pause while {not exists folder (parameter "whitelistfolder")}
    dos copy /Y "{((client folder of current site) as string) & "\__Download\ServicesWhitelist.txt"}" "{parameter "whitelist"}"
else
    dos copy /Y "{((client folder of current site) as string) & "\__Download\ServicesWhitelist.txt"}" "{parameter "whitelist"}"
endif

// Delete any old versions of files 'runningservices.txt' and 'blacklist.txt'
delete "{(parameter "runningservices")}"
delete "{(parameter "blacklist")}"

// Create the list of running services on this target
createfile until EOF
{concatenation "%0d%0a" of (service names of running services)}
EOF

// Copy the list of running services over to the Client directory
move __createfile "{(parameter "runningservices")}"


// Wait until the list of running services are copied.
// Compare the list of running services to the White List and create a 'blacklist' of services to be stopped
pause while {not exists file (parameter "runningservices")}
dos findstr /vixg:"{(parameter "whitelist")}" "{(parameter "runningservices")}" > "{(parameter "blacklist")}"

// Wait until the blacklist.txt is created
pause while {not exists file (parameter "blacklist")}

// Stop each service in the 'blacklist.txt' file
dos for /F "usebackq tokens=*" %A in ("{(parameter "blacklist")}") do sc stop "%A"
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.

Action 2

Action Link Click here to stop ALL services in the specified stoplist.
Script Type BigFix Action Script
///////////////////////////////////
// TO SET DIFFERENT FILE NAMES AND
// LOCATIONS CHANGE THE FOLLOWING
// PARAMETER VALUES
///////////////////////////////////

parameter "clientfolder" = "{(parent folder of client as string)}"
parameter "whitelistfolder" = "{(parameter "clientfolder" & "\ServicesWhitelist")}"
parameter "stoplist" = "{parameter "whitelistfolder" & "\stoplist.txt"}"

// -END- PARAMETER DECLARATIONS



// Download the stoplist file from the Root Server
download now as stoplist.txt http://ROOTSERVERNAME:52311/CustomDownloads/ServicesWhitelist/stoplist.txt
pause while {not exists file "__Download\stoplist.txt"}

// Check for the existence of the 'ServicesWhitelist' directory in the Client Folder on the target
// If the directory exists, just copy the file over, if not, create the folder and copy the file over
if {not exists folder (parameter "whitelistfolder")}
    dos mkdir "{parameter "whitelistfolder"}"
    pause while {not exists folder (parameter "whitelistfolder")}
    dos copy /Y "{((client folder of current site) as string) & "\__Download\stoplist.txt"}" "{parameter "stoplist"}"
else
    dos copy /Y "{((client folder of current site) as string) & "\__Download\stoplist.txt"}" "{parameter "stoplist"}"
endif



// Stop each service in the 'stoplist.txt' file
dos for /F "usebackq tokens=*" %A in ("{(parameter "stoplist")}") do sc stop "%A"
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.

Action 3

Action Link Click here to stop a SINGLE Windows service
Script Type BigFix Action Script
// Ask the operator for the name of the service to be stopped
action parameter query "servicename" with description "Enter the service name of the Windows service you wish to stop:"

// stop the service
dos sc stop "{parameter "servicename"}"
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.

Action 4

Action Link Click here to start a SINGLE Windows service
Script Type BigFix Action Script
// Ask the operator for the name of the service to be started
action parameter query "servicename" with description "Enter the service name of the Windows service you wish to start:"

// start the service
dos sc start "{parameter "servicename"}"
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!