Windows Develop Bookmark and Share   
 index > Windows Forms Sample Applications > Permission Denied :'getObject'
 

Permission Denied :'getObject'

Hi, this is ramana SV.

i wrote some script in WSH (sample.vbs), the intesion of the application is when i execute the program, i want other system details(RAM,Processor Speed, HDD,, Other's). But when i execute the program i got some error message That is"Permission denied "'GetObject'.

Below is MY Script CODE.

---------------------------------------------------------------------------------------------------------------------

strComputer = "mypc" 'system Name
'Set objWMIService = GetObject("winmgmts:"& "\\" & strComputer & "\root\cimv2")
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Set objComputer = GetObject("WinNT:\\" & strComputer & "Administrator")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Account where Name = '" & Administrator& "'")

Set objNetwork = Wscript.CreateObject("Wscript.Network")
Set objStdOut = WScript.StdOut
Set colComputers =objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objComputer in colComputers
objStdOut.WriteLine objNetwork.ComputerName
Wscript.Echo objComputer.Username
Wscript.Echo objComputer.TotalPhysicalMemory
' WScript.Echo " Processor Speed: " objComputer.ProcessorSpeed
' script.Echo objComputer.ComputerName
' Wscript.Echo " OSType: " objComputer.OSType
' Wscript.Echo objComputer.Manufacturer
Wscript.Echo objComputer.Model
' Wscript.Echo objComputer.NumberOfProcessors
Next
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
For Each objItem in colItems
'objItem.PowerManagementSupported
Wscript.Echo "Processor Name & Speed: " & objItem.Name
'Wscript.Echo "ProcessorType: " & objItem.ProcessorType


objStdOut.Close
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PhysicalMemory",,48)
For Each objItem in colItems
if objItem.Capacity > 900000000 and objItem.Capacity < 1900000000 then
amount = "1gb"
end if
if objItem.Capacity > 500000000 and objItem.Capacity < 900000000 then
amount = "512mb"
end if
if objItem.Capacity > 250000000 and objItem.Capacity < 500000000 then
amount = "256mb"
end if
if objItem.Capacity > 125000000 and objItem.Capacity < 250000000 then
amount = "128mb"
end if
if objItem.Capacity > 6200000 and objItem.Capacity < 125000000 then
amount = "64mb"
end if
if objItem.Capacity > 30000000 and objItem.Capacity < 62000000 then
amount = "32mb"
end if
wscript.echo(objItem.DeviceLocator & "RAM: " & amount & ", " & Speed & "")
Next


--------------------------------------------------------------------------------------------------------------------

pls Help me about this problem.

waitng 4 u r reply

Thank you

Ramanan SV

S.V.Ramana  Saturday, March 31, 2007 10:54 AM

Hi

Check out this will help you

http://support.microsoft.com/kb/916254

JB P

JBP0007  Wednesday, May 02, 2007 8:49 PM

Hi use as per bellow

On Error Resume Next

WMI QUERY for GET OBJECT

If Err.Number <> 0 Then
Wscript.Echo "Error: " & Err.Number
Wscript.Echo "Error (Hex): " & Hex(Err.Number)
Wscript.Echo "Source: " & Err.Source
Wscript.Echo "Description: " & Err.Description
Err.Clear

Else

YOUR CODE

End If

It will echo when it get error and you can use that part for other work also like sening email, runing your code differently.

Enjoy.

JB P

JBP0007  Wednesday, May 02, 2007 9:25 PM

You can use google to search for other answers

Custom Search

More Threads

• Terrarium Challenge
• Problem occured during installing, a newer need help
• Modeling ASP.net security
• Terrarium b1.0.21.281 available here...
• Only one WebServiceBinding error
• Urgent !!!! please ;)
• I don't know this is an easy thing to answer but how do you save it as a dll?
• Installer Issues
• PocketVision vs Offline App Block
• Server