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)
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

If strMode = "Auto" Then
ClientInstalledAndAuto = True
ClientInstalledAndAuto = False
If Len(strMode) = 0 Then
WshShell.LogEvent 0, "Novell ZENworks Agent Service not found."
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.

Joshua Brannon
0 Comments   [ - ] Hide Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity


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 '<%',
Answered 04/30/2009 by: VBScab
Red Belt

Please log in to comment
Awesome! Thank you very much for the help. It worked perfectly!

Joshua Brannon
Answered 04/30/2009 by: jbrannon
Yellow Belt

Please log in to comment