VB Script to install NS 7 Altiris Agent

book

Article ID: 179850

calendar_today

Updated On:

Products

Management Platform (Formerly known as Notification Server)

Issue/Introduction

 

Resolution

Question
Is there a VB Script that can be used in a login script to install the Altiris Agent?

Answer

The following VBScript is provided as-is. It is not guaranteed to meet the needs of every possible situation but is provided as a template or a guide for use in your environment. It may need to be modified or replaced to function fully in your environment.   

Below is a vbscript that can be used to accomplish this. It requires that the AeXAgentUtil from NS 6 be copied into the "NSCAP\Bin\Win32\X86\NS Client Packge" folder on the NS 7 server and renamed to AeXAgentUtilNS6.exe. Also copy the AeXAgentUtil from NS 7 to the "NSCAP\Bin\Win32\X86\NS Client Packge" folder on the NS 7 server and renamed to AeXAgentUtilNS7.exe

The script does the following:

1. Looks in the registry and if the InstallDir key doesn't exist assumes that the Altiris Agent is not installed on the client and pulls that NS 7 Altiris Agent install.

2. If the key exists, compares versions to see if the version is less than 7.0 and if it is, runs the NS 6 version of the AeXAgentUtil to uninstall the NS 6 agent plug-ins. It then runs the NS 7 Altiris Agent installer. Finally it redirects the Altiris Agent to the NS 7 server using the NS 7 version of the AexAgentUtil.exe. (Note: There is a issue where the NS 6 to NS 7 agent upgrade via a pull process does not redirect the agent to the NS 7 server.)

3. If the Altiris Agent is already at a NS 7 version it does nothing.

Note: The paths in the script need to be modified to match your system.

Option Explicit

Dim AltirisIns, oFS, wshShell, AgentVer, strCommand
set oFS = WScript.CreateObject("Scripting.FileSystemObject")
Set WshShell = Wscript.createObject("wscript.shell")

On Error Resume Next
Err.clear
AltirisIns = WshShell.RegRead ("HKLM\Software\Altiris\Altiris Agent\InstallDir")
If Hex(Err) = "80070002" Then

    ' "No registry exists. Assuming No agent exists. Installing NS7 Agent

                   'wscript.echo "Configuring drive mapping n"
                    WshShell.Run "net use n: ""
\\NS7-KS4\NSCap\Bin\Win32\X86\NS Client Package""",0,true
     'wscript.echo "Installing NS7 Agent"
                    WshShell.Run "cmd /c n:\aexnsc.exe -s -a ns=""NS7-KS4"" nsweb=""
http://NS7-KS4/Altiris/"" NOTRAYICON NOSTARTMENU /s",0,true
                   'wscript.echo "Redirecting Agent to NS 7 Server"
     'WshShell.Run "cmd /c n:\AeXAgentUtilNS7.exe /Server:NS7-ks4",0,true
     'wscript.echo "Removing drive mapping"
      WshShell.Run "net use n: /delete",0,true
 
Else

'if oFS.FileExists( AltirisIns + "\AexNSAgent.exe") Then "**** Not using this to test existence ****

    'wscript.echo "agent exists"
     AgentVer = WshShell.RegRead ("HKLM\Software\Altiris\Altiris Agent\version")

    'wscript.echo "Testing version"
    'wscript.echo "Version = " & AgentVer
    'wscript.echo "path = " & AltirisIns

            If StrComp (AgentVer, "7.0.0.0", vbBinaryCompare) = -1 Then
    
     'This is an NS 6 Agent - Uninstall Subagents
     'strCommand = AltirisIns + "\AeXAgentUtil.exe /uninstallAgents"
     'strCommand = Chr(34) & Chr(34) & Chr(34) & AltirisIns & "\AeXAgentUtil.exe /UninstallAgents" & Chr(34) & Chr(34) & Chr(34)
     'wscript.echo "path = " & strCommand
          
 
             'wscript.echo "Running Agent Plug-ins uninstall"
             'WshShell.Run strCommand,0,false   *** Couldn't get this or command below to run ****
             'wshshell.run "cmd /c ""e:\program file\altiris\altiris agent\aexagentutil.exe"" /UninstallAgents"
 
             'wscript.sleep(120000)
      'wscript.echo "Pause"

           'wscript.echo "Configuring drive mapping n"
                    WshShell.Run "net use n: ""
\\NS7-KS4\NSCap\Bin\Win32\X86\NS Client Package""",0,true
     'wscript.echo "Uninstalling Agent Plug-ins"
      WshShell.Run "cmd /c n:\AeXAgentUtilNS6.exe /UninstallAgents",0,true
     'wscript.sleep(120000)
     'wscript.echo "Installing NS7 Agent"
                    WshShell.Run "cmd /c n:\aexnsc.exe -s -a ns=""NS7-KS4"" nsweb=""
http://NS7-KS4/Altiris/"" NOTRAYICON NOSTARTMENU /s",0,true
                   'wscript.echo "Redirecting Agent to NS 7 Server"
      WshShell.Run "cmd /c n:\AeXAgentUtilNS7.exe /Server:NS7-ks4",0,true
     'wscript.echo "Removing drive mapping"
      WshShell.Run "net use n: /delete",0,true
              End If
  

End If
Wscript.Quit