vbscript to run remotely
Hi Friends,
Currently I am working with antivirus team, and we have to run 1 script remotely by using psexec command. By using psexec switch we accessed command prompt of the machine, and we ran below script, but it is not updating settings. Do we have to write such scripts in other methods? Please guide.
Currently I am working with antivirus team, and we have to run 1 script remotely by using psexec command. By using psexec switch we accessed command prompt of the machine, and we ran below script, but it is not updating settings. Do we have to write such scripts in other methods? Please guide.
'==========================================================================
' NAME: EPO SETTINGS.vbs
' DATE : 03/01/2010
' COMMENT: This script, does EPO SETTINGS.
'==========================================================================
On Error Resume Next
Dim OBJFSO
Dim OBJSHELL
Set OBJFSO = CreateObject("SCRIPTING.FILESYSTEMOBJECT")
Set OBJSHELL = CreateObject("WSCRIPT.SHELL")
A = OBJSHELL.CurrentDirectory
STRPROGRAMFILES = OBJSHELL.ExpandEnvironmentStrings("%PROGRAMFILES%")
STRTEMP = OBJSHELL.ExpandEnvironmentStrings("%TEMP%")
PATH1 = A & "\FRAMEPKG\FRAMEPKG.EXE"
PATH2 = STRTEMP & "\FRAMEPKG.EXE"
PATH3 = STRPROGRAMFILES & "\McAfee\Common Framework\CmdAgent.exe"
PATH4 = STRPROGRAMFILES & "\McAfee\Virus Scan Enterprise\mcupdate.exe"
COMMANDPATH2 = Chr(34) & PATH2 & Chr(34)
COMMANDPATH3 = Chr(34) & PATH3 & Chr(34) & " /P"
COMMANDPATH4 = Chr(34) & PATH4 & Chr(34)
'==========================================================================
'THIS PIECE OF CODE, COPIES FRAMEPKG.EXE TO C:\TEMP LOCATION
OBJFSO.CopyFile PATH1, PATH2
'==========================================================================
'THIS PIECE OF CODE, RUNS FRAMEPKG.EXE
OBJSHELL.RUN COMMANDPATH2,1,True
'==========================================================================
'THIS PIECE OF CODE, DELETES MCAFEE AGENT GUID
OBJSHELL.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\ePolicy Orchestrator\Agent\AgentGUID"
'==========================================================================
'THIS PIECE OF CODE, RESTARTS SERVICE
OBJSHELL.Run "SC STOP McAfeeFramework"
OBJSHELL.Run "SC START McAfeeFramework"
'==========================================================================
'THIS PIECE OF CODE, WILL RUN CMDAGENT.EXE WITH PARAMETER /P
OBJSHELL.RUN COMMANDPATH3,1,True
'==========================================================================
'THIS PIECE OF CODE, WILL RUN MCUPDATE.EXE
OBJSHELL.RUN COMMANDPATH4,1,True
WScript.Quit
'==========================================================================
'END
0 Comments
[ + ] Show comments
Answers (4)
Please log in to answer
Posted by:
kapil.kathuria
14 years ago
Posted by:
airwolf
14 years ago
Posted by:
anonymous_9363
14 years ago
This is getting boring now...
Why bother with script when all you're doing is calling command line tools? These tools have only rudimentary error-reporting - if any - meaning that your script is seriously flawed. For example, after 'SC STOP McAfeeFramework', how do you know that the service stopped? You don't test for its stopped state, but just assume that it did. As usual, that will probably work most of the time but what about the time it doesn't? What if it's the CEO's machine which is down because your script failed? Egg on face, IT's reputation even more damaged and so on.
Either stick with DOS batch/command files or get some proper scripting skills and write proper code with error-checking.
As already stated, WMI will serve you well for all the tasks carried out by your script: service control, process execution and so on.
Why bother with script when all you're doing is calling command line tools? These tools have only rudimentary error-reporting - if any - meaning that your script is seriously flawed. For example, after 'SC STOP McAfeeFramework', how do you know that the service stopped? You don't test for its stopped state, but just assume that it did. As usual, that will probably work most of the time but what about the time it doesn't? What if it's the CEO's machine which is down because your script failed? Egg on face, IT's reputation even more damaged and so on.
Either stick with DOS batch/command files or get some proper scripting skills and write proper code with error-checking.
As already stated, WMI will serve you well for all the tasks carried out by your script: service control, process execution and so on.
Posted by:
Puneetha
13 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.