Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista General Discussion > access denied using wmi

Reply
Thread Tools Display Modes

access denied using wmi

 
 
rac8006
Guest
Posts: n/a

 
      01-20-2008

I new to vbscript programming. I have the following script that works fine
in XP but fails in Vista home premium. It get access denied (return code 2)
for the system processes. It won't print the owner or commandline for systems
processes. I'm looged in with admin priv's on both os's. Any ideas whats
wrong?

Thanks

strComputer = "."
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
'================================================= =============
Const Data_Path = "C:\temp\"
Const fileName = "process.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
If Not FSO.FileExists(Data_Path & filename) Then
Set f = fso.OpenTextFile(Data_Path & fileName,2, True)
Else
Set f = fso.OpenTextFile(Data_Path & fileName,8)
End If
strComputer = "."
Set colProcesses = GetObject("winmgmts:" & _
"{impersonationLevel=impersonate}!\\" & strComputer & _
"\root\cimv2").ExecQuery("Select * from Win32_Process")
For Each objProcess in colProcesses
Return = objProcess.GetOwner(strNameOfUser)
f.WriteLine Return & vbTab & objProcess.Name & vbTab & StrNameOfUser& vbTab
& objProcess.CommandLine
Next
 
Reply With Quote
 
 
 
 
David Sanders
Guest
Posts: n/a

 
      01-20-2008
rac8006 wrote:
> I new to vbscript programming. I have the following script that works fine
> in XP but fails in Vista home premium. It get access denied (return code 2)
> for the system processes. It won't print the owner or commandline for systems
> processes. I'm looged in with admin priv's on both os's. Any ideas whats
> wrong?
>
> Thanks
>
> strComputer = "."
> Const ForReading = 1
> Const ForWriting = 2
> Const ForAppending = 8
> '================================================= =============
> Const Data_Path = "C:\temp\"
> Const fileName = "process.txt"
> Set fso = CreateObject("Scripting.FileSystemObject")
> If Not FSO.FileExists(Data_Path & filename) Then
> Set f = fso.OpenTextFile(Data_Path & fileName,2, True)
> Else
> Set f = fso.OpenTextFile(Data_Path & fileName,8)
> End If
> strComputer = "."
> Set colProcesses = GetObject("winmgmts:" & _
> "{impersonationLevel=impersonate}!\\" & strComputer & _
> "\root\cimv2").ExecQuery("Select * from Win32_Process")
> For Each objProcess in colProcesses
> Return = objProcess.GetOwner(strNameOfUser)
> f.WriteLine Return & vbTab & objProcess.Name & vbTab & StrNameOfUser& vbTab
> & objProcess.CommandLine
> Next

Right click on it and select "run as administrator"
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Denied, Access Denied- like a broken record! Sam Windows Vista General Discussion 7 04-26-2008 04:54 AM
Can't Access Printer- Access Denied. Jordan H. Windows Vista Networking 31 01-21-2008 02:22 AM
When standard users access Vista registry remotely, Access Denied Gayle Windows Vista Administration 1 10-10-2007 04:48 PM
Access Denied trying to access Vista PC Ron Windows Vista Networking 7 09-30-2007 02:45 PM
Access is denied message when trying to access a remote printer MarkC Windows Vista Printing / Faxing / Scanning 1 03-09-2007 12:34 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59