Help WMI Error in VBS

Tech-Archive recommends: Fix windows errors by optimizing your registry



I need help with debugging this code. the code works for everything
except in once instance where a server name is in the list, but not on
the network the entire scrips fails at this point at SET objWMIService
= GetObject("winmgmts://" & Computer) with a permission denied error.
I though i was error trapping with the next line, but it is almost like
the script never gets to that point before blowing up. can someone take
a look and see what i am missing.

-TIA-


'Objective: Find Disk Free Space in all the listed servers and write to
a database, and add error log.

Const kbConversion= 1024
Dim AdCn, AdRec, AdRec1, SQL
Set AdCn = CreateObject("ADODB.Connection")
Set AdRec = CreateObject("ADODB.Recordset")
Set AdRec1 = CreateObject("ADODB.Recordset")
' NOTE: Change the connection string according to your environment.
AdCn.Open = "Provider=SQLOLEDB.1; Data Source=sdlc;Integrated
Security=SSPI;Persist SecurityInfo=False; Initial Catalog=DISK_Dev;
user id=diskuser; password=disk"
SQL1 = "SELECT SystemName FROM System_Monitor_List WHERE MonitorEnabled
= 1 AND MonitorDiskSpace = 1"
'wscript.echo SQL1 ' Debugging
AdRec1.Open SQL1, AdCn,1,1
'Adrec1.movefirst
DO UNTIL AdRec1.EOF
Computer = AdRec1("SystemName")
' wscript.echo Computer ' Debugging
SET objWMIService = GetObject("winmgmts://" & Computer)
If err.number <> 0 THEN
ErrorSQL="INSERT INTO System_Monitor_Log_Errors (SystemName,
SystemError) VALUES ('" & Computer & "','" & Err.description & "')"
wscript.echo "Start Error :" & ErrorSQL ' Debugging
AdRec.Open ErrorSQL, AdCn,1,1
ELSE
SET colLogicalDisk = objWMIService.InstancesOf("Win32_LogicalDisk")
FOR EACH objLogicalDisk IN colLogicalDisk
IF err.number <> 0 THEN
ErrorSQL="INSERT INTO System_Monitor_Log_Errors (SystemName,
SystemError) VALUES ('" & Computer & "','" & Err.description & "')"
wscript.echo "Loop Error: " & ErrorSQL ' Debugging
AdRec.Open SQL, AdCn,1,1
END IF
IF objLogicalDisk.drivetype=3 THEN
SQL="INSERT INTO System_Monitor_Log_Disk_Space (SystemName, Drive,
Size, FreeSpace, AuditDateTime) VALUES ('" & Computer & "','" &
objLogicalDisk.DeviceID & "','" & objLogicalDisk.size/kbConversion &
"','" & objLogicalDisk.freespace/kbConversion & "','" & now() & "')"
wscript.echo sql ' Debugging
AdRec.Open SQL, AdCn,1,1
END IF
NEXT
END IF
Adrec1.movenext
err.Clear
LOOP

.



Relevant Pages

  • *****UNABLE TO MAP THE DEBUG START PAGE URL TO A MACHINE NAME - HELL ON EARTH - PLEASE HELP!
    ... ASP.Net debugging through a firewall. ... Terminal Services to log into the remote server and debug locally. ... "Were the proper setup programs run to install ASP.NET or ATL Server ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: QUERY: debugging ASP VBScript
    ... > the web application running and whenever I want to debug I follow these ... >> on the client and the server. ... In order to debug ASP pages, ... you should enable debugging manually on the server ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: how analyze malfunctioning asp.net application?
    ... a product server, correct? ... unhealthy and teh worker process will be recycled. ... production debugging in your environment. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: QUERY: debugging ASP VBScript
    ... at a breakpoint. ... > the web application running and whenever I want to debug I follow these ... >> on the client and the server. ... you should enable debugging manually on the server ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: QUERY: debugging ASP VBScript
    ... effect to the debugging. ... >> dllhost.exe and click on attach. ... >> the web application running and whenever I want to debug I follow these ... >>> on the client and the server. ...
    (microsoft.public.dotnet.framework.aspnet)