JustScriptIt
Technical User
I am trying to create a script that will stop a service, troubleshoot, and then start the service.
So far, I am able to stop the service, but I am unable to start the service. I actually have to go into the computer and start it manually.
Below is the code I have so far:
So far, I am able to stop the service, but I am unable to start the service. I actually have to go into the computer and start it manually.
Below is the code I have so far:
Code:
' Must be run from command prompt with System Domain rights, on Windows XP or 2000
' It asks for text file with list of computers to delete the hardware ID
' Then it asks for SEP install password
Option Explicit
Dim objInputFSO
Dim strInputFile, strData, arrLines, strLine
Dim objPassword, strPassword, objShell, objWMIService
Dim oReg
Dim strComputer, strKeyPath, strValueName, strValue, dwValue
Dim strPath, strVersion, intComm, strGroup, strPolicy, strHardware, strVirus, strIPS, intNTP
const HKEY_CURRENT_USER = &H80000001
const HKEY_LOCAL_MACHINE = &H80000002
'Create an Input File System Object
Set objInputFSO = CreateObject("Scripting.FileSystemObject")
'Name of the input text file
strInputFile = InputBox("What is the name of file with list of computers?")
'Open the text file - strData now contains the whole file
strData = objInputFSO.OpenTextFile(strInputFile,1).ReadAll
'Split the text file into lines
arrLines = Split(strData,vbCrLf)
'Create Password Object
Set objPassword = CreateObject("ScriptPW.Password")
'Prompt User for Password
WScript.StdOut.Write "Please enter your password:"
'Input is stored in strPassword
strPassword = objPassword.GetPassword()
'Create Shell Object
Set objShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\" & "." & "\root\cimv2:Win32_Process")
'For loop to go through list of computers
On Error Resume Next
'Step through the lines
For Each strLine in arrLines
strComputer = strLine
Set oReg=GetObject( _
"winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
'Find the SEP Installation path
strKeyPath = "SOFTWARE\Symantec\Symantec Endpoint Protection\AV"
strValueName = "Home Directory"
oReg.GetStringValue _
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strPath = strValue
'Stop smc.exe service
objWMIService.Create(strPath & "\smc.exe -stop " & strPassword)
'troubleshooting tasks
'troubleshooting tasks
'troubleshooting tasks
'Start smc.exe service
objWMIService.Create(strPath & "\smc.exe -start ")
Next
'Cleanup
Set objInputFSO=Nothing