Hey
I hope it's okay i took the time to create how i see your script, and how i think it should be.
I don't know if you know this, but "Option explicit" means that you need to declare all your variables.
i just did it with the ones that i know you will have problems with, you might need also to declare, colListOfServices and objService.
But run the script, and if it says they haven't been declared, simply write it in the "Dim" section.
I have sectioned your declarations in 2, strings and objects, really it doesn't mean anything how you do it, but it's a bit easier to see.
Also it's good practice to call your variables either, obj (for objects) and str (for strings), but again, if you can decifer your code, it doesn't really matter. (an example of this could be, strNsVer and strNsVerx86 and strRegkey, all of these are strings.)
Option Explicit
'on error resume next
Dim WSHShell, wshEnvironment, FSO, objWMIService
Dim RegKey, nsver, nsverx86, strRunProgram, strServiceName
Set WSHShell = CreateObject("WScript.Shell")
Set wshEnvironment = wshShell.Environment("System")
Set fso = CreateObject("scripting.filesystemobject")
RegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\ALTIRIS\ALTIRIS AGENT\"
nsver = WSHShell.RegRead(RegKey & "Version")
RegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ALTIRIS\ALTIRIS AGENT\"
nsverx86 = WSHShell.RegRead(RegKey & "Version")
If not nsver = "7.1.8280.15280" Or Not nsverx86 = "7.1.8280.15280" Then
FSO.CopyFile "\\www.myserver.com\NS Client Package$\AeXNSC.exe", "c:\"
end if
'Stop Altiris Service
strServiceName = "AeXNSClient"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objService in colListOfServices
objService.StopService()
Next
If fso.fileExists( "c:\program files\altiris\altiris agent\aexnsagent.exe") Then
WSHShell.Run ("""C:\Program Files\Altiris\Altiris Agent\aexagentutil.exe"" /uninstallagents /clean"),,True
end if
If fso.fileExists( "c:\program files (x86)\altiris\altiris agent\aexnsagent.exe") Then
WSHshell.Run ("""C:\Program Files (x86)\Altiris\Altiris Agent\aexagentutil.exe"" /uninstallagents /clean"),,True
end if
WSHShell.Run ("""c:\AeXNSC.exe"" -s -a ns=www.myserver.com nsweb=http://www.myserver.com/altiris NOSTARTMENU /s"),,True