/build/static/layout/Breadcrumb_cap_w.png

Vb strart up script/ trying to deploy zenworks agent

I am trying to deploy the ZenWorks agent through group policy using a VB start up script. I am getting a Windows Script Host error (The system cannot find the file specified. Line 17 Char 2). Here is my script.

Option Explicit

Dim strSiteCode
Dim strMode
Dim strParams

If WScript.arguments.count > 0 Then
strParams = WScript.arguments(0)
End If

Dim WshShell, lngExitCode
Set WshShell = CreateObject("WScript.Shell")

If ClientInstalledAndAuto("") = False Then
Dim oExec, strCmdLine
strCmdLine = ScriptDir & "\PreAgentPkg_AgentComplete.exe" & strParams
lngExitCode = WshShell.Run(strCmdLine, 0, True)
WshShell.LogEvent 0, "Started ZCM agent install: """ & strCmdLine & """" & CHR(10) & "Exit code was " & CSTR(lngExitCode)
Else
WshShell.LogEvent 0, "ZCM agent is installed and set to Automatic. No action required."
End If

Function ScriptDir
ScriptDir = Left(WScript.ScriptFullName,Len(WScript.ScriptFullName) - Len(WScript.ScriptName) -1)
End Function

Function ClientInstalledAndAuto(strComputerName)
ClientInstalledAndAuto = False
On Error Resume Next

If Len(strComputerName) = 0 Then
strComputerName = "."
End If

Dim objWMI, objList, objItem

Set objWMI = GetObject("winmgmts://" & strComputerName & "/root/cimv2")
If err.number <> 0 Then
Exit Function
End If

strMode = ""

Set objList = objWMI.ExecQuery("Select StartMode from Win32_Service where Name=""Novell ZENworks Agent Service""")
For Each objItem In objList
strMode = objItem.StartMode
Exit For
Next

If strMode = "Auto" Then
ClientInstalledAndAuto = True
Else
ClientInstalledAndAuto = False
If Len(strMode) = 0 Then
WshShell.LogEvent 0, "Novell ZENworks Agent Service not found."
Else
WshShell.LogEvent 0, "Novell ZENworks Agent Service is to: " & strMode
End If
End If

End Function

I have placed the agent exe file in the Group Policy, start up scripts folder that my script is in.

I need help in the worst way. I anyone can help me, it would be much appreciated.

Thanks
Joshua Brannon

0 Comments   [ + ] Show comments

Answers (2)

Posted by: anonymous_9363 15 years ago
Red Belt
0
Three things:

- The tortuous route to get ScriptDir is unnecessary. Have a look at the FileSystemObject object's methods and properties. You can get path, filename, ParentFolder, etc, etc.
- I suspect your strCmdLine has a space in it, in which case you need to quote it. I normally recommend that, rather than clutter up your string with actual quote marks (which eventually become invisible - put 4 consecutive quote marks on a page and then try to visually count them: are there 4? Or 3? ), you use Chr(34):strCmdLine = ScriptDir & "\PreAgentPkg_AgentComplete.exe" & strParams thus becomes strCmdLine = Chr(34) & ScriptDir & "\PreAgentPkg_AgentComplete.exe" & Chr(34) & strParams
- Please use the CODE tag when posting code or other lengthy text. Access the tag by clicking the button marked '<%',
Posted by: jbrannon 15 years ago
Yellow Belt
0
Awesome! Thank you very much for the help. It worked perfectly!

Thanks
Joshua Brannon
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ