Stop Windows Services Before Patching
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
26928 | |
Beta - Preliminary testing ready for more | |
Stop Windows Services Before Patching | |
PTCH | |
Utility | |
Internal | |
Informational | |
4/15/2014 12:00:00 AM | |
Services, Stop, Start, Patches, Patching, Windows | |
True | |
mxc0bbn on 4/20/2022 8:39:49 PM | |
mxc0bbn on 4/20/2022 8:39:49 PM | |
1926 Views / 7 Downloads | |
![]() ![]() ![]() ![]() ![]() |
Relevance
Actions
Action 1
///////////////////////////////////
// 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"
This action will be considered successful when the applicability relevance evaluates to false.
Action 2
///////////////////////////////////
// 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"
This action will be considered successful when the applicability relevance evaluates to false.
Action 3
// 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"}"
This action will be considered successful when the applicability relevance evaluates to false.
Action 4
// 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"}"
This action will be considered successful when the applicability relevance evaluates to false.
Sharing
Social Media: |