Guys , I'm stumped on this one
I have a real simple script that writes to a file the current CPU % time
But if I run it from an Agent procedure it doesn't work. The Machine is a Windows 2003 Server SP2
I've checked the kworking Folder Permissions ( set them to "everyone" )
Tried running as User , System etc etc
It just fails
The odd thing is it does run on some 2003 Servers , not all.
So any suggestions ?
The script I'm using to test is as beow
On Error Resume Next
Dim PreviousCPU, CPUAvg, CPUAverage
Set ArgObj = Wscript.ArgumentsfileName = ArgObj(0)PreviousCPU = ArgObj(1)
Const wbemFlagReturnImmediately = &h10Const wbemFlagForwardOnly = &h20strComputer = "."
Set objWMIService = GetObject( "winmgmts://" & strComputer & "/root/CIMV2" )Set colInstances = objWMIService.ExecQuery( "SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly )For Each objInstance In colInstances If ObjInstance.Name = "_Total" Then CPUTime = objInstance.PercentProcessorTime End IfNext
set objFile = objFSO.CreateTextFile(fileName,True)CPUAvg = Round((CPUTime / 2 + PreviousCPU / 2),2)objFile.Writeline CPUAvgobjFile.Close
I had the same issues with some scripts, that for some reason need admin rights to run.
Solved it with VBSEdit as a script editor and then convert it into an executable and run the exe instead in the Shell.
Hope this helps; btw VBSEdit is from AderSoft , you can download a trial