Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't get Hotfixes to list in ASP with VB Script.

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I am trying to get the HOTFIXES to list off a server via ASP web page. They will not list. Below is my code.
The only thing that list is the text "Server Hotfix Information".. The script will not go and get the hotfix info. If I run it by itself and not in a asp page, just vbscript, it runs fine..

response.write &quot;<u>Server Hotfix Information</u>&quot;
objWMIService = Server.GetObject(&quot;winmgmts:&quot; & &quot;{impersonationLevel=impersonate}!\\&quot; & strComputer & &quot;\root\cimv2&quot;)
colQuickFixes = Server.objWMIService.ExecQuery (&quot;Select * from Win32_QuickFixEngineering&quot;)

response.write &quot;<div style='padding:10 10;'>&quot;
response.write &quot;<table border=0 cellpadding=0 cellspacing=0 style='padding:0 5'>&quot;
For Each objQuickFix in colQuickFixes
response.write &quot;<u>Computer: &quot; & objQuickFix.CSName &&quot;</u>&quot;
response.write &quot;Description: &quot; & objQuickFix.Description
response.write &quot;Hot Fix ID: &quot; & objQuickFix.HotFixID
response.write &quot;Installation Date: &quot; & objQuickFix.InstallDate
response.write &quot;Installed By: &quot; & objQuickFix.InstalledBy
next
response.write &quot;</table>&quot;
response.write &quot;</div>&quot;
 
When you run this in a VBS, it runs in the security context of the actively logged-in user. When you run it thru ASP (assuming you are using Anonymous access), it runs as IUser_machine, which doesnt have the necessary privledges to access WMI.

Since you are familiar with WMI, refer to the ConnectServer method of SWbemLocator and modify your script to access WMI thru this method so that you can provide the necessary security credentials.

Jon Hawkins
 
actually the website uses windows authentication, not anonymous. I know it is pullying the correct credentials.
 
This will work, provided the security credentials are correct.

<%
strComputer=&quot;.&quot;
response.write &quot;<u>Server Hotfix Information</u>&quot;
Set objWMIService = GetObject(&quot;winmgmts:&quot; & &quot;{impersonationLevel=impersonate}!\\&quot; & strComputer & &quot;\root\cimv2&quot;)
Set colQuickFixes = objWMIService.ExecQuery(&quot;Select * from Win32_QuickFixEngineering&quot;)

response.write &quot;<div style='padding:10 10;'>&quot;
response.write &quot;<table border=0 cellpadding=0 cellspacing=0 style='padding:0 5'>&quot;
For Each objQuickFix in colQuickFixes
response.write &quot;<u>Computer: &quot; & objQuickFix.CSName &&quot;</u>&quot;
response.write &quot;Description: &quot; & objQuickFix.Description
response.write &quot;Hot Fix ID: &quot; & objQuickFix.HotFixID
response.write &quot;Installation Date: &quot; & objQuickFix.InstallDate
response.write &quot;Installed By: &quot; & objQuickFix.InstalledBy
next
response.write &quot;</table>&quot;
response.write &quot;</div>&quot;
%> Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top