Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - WMI Error 2

Reply
 
Old 11-17-2008   #1 (permalink)
Joe


 
 

WMI Error 2

I am running a VBScript to start an application and I am getting a return
error code of 2 (access denied).

Now I take it that the access denied is to the \\.\root\CIMV2, but how can I
verify this?

I get the same error whether using impersonationlevel=impersonate or
removing that.

Any help would be appreciated.

My System SpecsSystem Spec
Old 11-17-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: WMI Error 2


"Joe" <Joe@xxxxxx> wrote in message
news:7FD36CEF-FD36-4DB4-B3A0-BD5C6FF4072A@xxxxxx
Quote:

>I am running a VBScript to start an application and I am getting a return
> error code of 2 (access denied).
>
> Now I take it that the access denied is to the \\.\root\CIMV2, but how can
> I
> verify this?
>
> I get the same error whether using impersonationlevel=impersonate or
> removing that.
>
> Any help would be appreciated.
You don't usually need WMI to launch an application - the exec or run
methods of the WScript.Shell object will easily do it for you. Anyway -
let's have a look at your script.


My System SpecsSystem Spec
Old 11-17-2008   #3 (permalink)
Joe


 
 

Re: WMI Error 2

Script is attached. It is a simple sample program, but it is the basis for
the script
that we are planning on using.

Const HIDDEN_WINDOW = 0
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = HIDDEN_WINDOW
Set objProcess = GetObject( _
"winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create( _
"notepad.exe", null, objConfig, intProcessID)
wscript.echo errReturn

"Pegasus (MVP)" wrote:
Quote:

>
> "Joe" <Joe@xxxxxx> wrote in message
> news:7FD36CEF-FD36-4DB4-B3A0-BD5C6FF4072A@xxxxxx
Quote:

> >I am running a VBScript to start an application and I am getting a return
> > error code of 2 (access denied).
> >
> > Now I take it that the access denied is to the \\.\root\CIMV2, but how can
> > I
> > verify this?
> >
> > I get the same error whether using impersonationlevel=impersonate or
> > removing that.
> >
> > Any help would be appreciated.
>
> You don't usually need WMI to launch an application - the exec or run
> methods of the WScript.Shell object will easily do it for you. Anyway -
> let's have a look at your script.
>
>
>
My System SpecsSystem Spec
Old 11-17-2008   #4 (permalink)
Pegasus \(MVP\)


 
 

Re: WMI Error 2

I'm a strong believer in the KISS principle, hence I would use this code:

Set ObjWshShell = WScript.CreateObject("WScript.Shell")
ErrReturn = ObjWshShell.Run("notepad.exe")


"Joe" <Joe@xxxxxx> wrote in message
news:5E2E0835-4587-4AD4-B153-06D3093F78C1@xxxxxx
Quote:

> Script is attached. It is a simple sample program, but it is the basis
> for
> the script
> that we are planning on using.
>
> Const HIDDEN_WINDOW = 0
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" _
> & strComputer & "\root\cimv2")
> Set objStartup = objWMIService.Get("Win32_ProcessStartup")
> Set objConfig = objStartup.SpawnInstance_
> objConfig.ShowWindow = HIDDEN_WINDOW
> Set objProcess = GetObject( _
> "winmgmts:root\cimv2:Win32_Process")
> errReturn = objProcess.Create( _
> "notepad.exe", null, objConfig, intProcessID)
> wscript.echo errReturn
>
> "Pegasus (MVP)" wrote:
>
Quote:

>>
>> "Joe" <Joe@xxxxxx> wrote in message
>> news:7FD36CEF-FD36-4DB4-B3A0-BD5C6FF4072A@xxxxxx
Quote:

>> >I am running a VBScript to start an application and I am getting a
>> >return
>> > error code of 2 (access denied).
>> >
>> > Now I take it that the access denied is to the \\.\root\CIMV2, but how
>> > can
>> > I
>> > verify this?
>> >
>> > I get the same error whether using impersonationlevel=impersonate or
>> > removing that.
>> >
>> > Any help would be appreciated.
>>
>> You don't usually need WMI to launch an application - the exec or run
>> methods of the WScript.Shell object will easily do it for you. Anyway -
>> let's have a look at your script.
>>
>>
>>

My System SpecsSystem Spec
Old 11-17-2008   #5 (permalink)
Joe


 
 

Re: WMI Error 2

Agreed, that would be nice.

However it would also be nice to figure out where this is actually failing.
And then being able to fix the underlying cause.

"Pegasus (MVP)" wrote:
Quote:

> I'm a strong believer in the KISS principle, hence I would use this code:
>
> Set ObjWshShell = WScript.CreateObject("WScript.Shell")
> ErrReturn = ObjWshShell.Run("notepad.exe")
>
>
> "Joe" <Joe@xxxxxx> wrote in message
> news:5E2E0835-4587-4AD4-B153-06D3093F78C1@xxxxxx
Quote:

> > Script is attached. It is a simple sample program, but it is the basis
> > for
> > the script
> > that we are planning on using.
> >
> > Const HIDDEN_WINDOW = 0
> > strComputer = "."
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate}!\\" _
> > & strComputer & "\root\cimv2")
> > Set objStartup = objWMIService.Get("Win32_ProcessStartup")
> > Set objConfig = objStartup.SpawnInstance_
> > objConfig.ShowWindow = HIDDEN_WINDOW
> > Set objProcess = GetObject( _
> > "winmgmts:root\cimv2:Win32_Process")
> > errReturn = objProcess.Create( _
> > "notepad.exe", null, objConfig, intProcessID)
> > wscript.echo errReturn
> >
> > "Pegasus (MVP)" wrote:
> >
Quote:

> >>
> >> "Joe" <Joe@xxxxxx> wrote in message
> >> news:7FD36CEF-FD36-4DB4-B3A0-BD5C6FF4072A@xxxxxx
> >> >I am running a VBScript to start an application and I am getting a
> >> >return
> >> > error code of 2 (access denied).
> >> >
> >> > Now I take it that the access denied is to the \\.\root\CIMV2, but how
> >> > can
> >> > I
> >> > verify this?
> >> >
> >> > I get the same error whether using impersonationlevel=impersonate or
> >> > removing that.
> >> >
> >> > Any help would be appreciated.
> >>
> >> You don't usually need WMI to launch an application - the exec or run
> >> methods of the WScript.Shell object will easily do it for you. Anyway -
> >> let's have a look at your script.
> >>
> >>
> >>
>
>
>
My System SpecsSystem Spec
Old 11-17-2008   #6 (permalink)
Pegasus \(MVP\)


 
 

Re: WMI Error 2

I forgot to mention in my previous reply that I ran your code on my machine
without any problems. If you insist on using WMI to invoke external
applications then you might consider the simple code below:
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
Err = objWMIService.Create("Notepaad.exe", Null, Null, intProcessID)

It comes from here:
http://www.microsoft.com/technet/scr...7/hey0426.mspx


"Joe" <Joe@xxxxxx> wrote in message
news:5E2E0835-4587-4AD4-B153-06D3093F78C1@xxxxxx
Quote:

> Script is attached. It is a simple sample program, but it is the basis
> for
> the script
> that we are planning on using.
>
> Const HIDDEN_WINDOW = 0
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate}!\\" _
> & strComputer & "\root\cimv2")
> Set objStartup = objWMIService.Get("Win32_ProcessStartup")
> Set objConfig = objStartup.SpawnInstance_
> objConfig.ShowWindow = HIDDEN_WINDOW
> Set objProcess = GetObject( _
> "winmgmts:root\cimv2:Win32_Process")
> errReturn = objProcess.Create( _
> "notepad.exe", null, objConfig, intProcessID)
> wscript.echo errReturn
>
> "Pegasus (MVP)" wrote:
>
Quote:

>>
>> "Joe" <Joe@xxxxxx> wrote in message
>> news:7FD36CEF-FD36-4DB4-B3A0-BD5C6FF4072A@xxxxxx
Quote:

>> >I am running a VBScript to start an application and I am getting a
>> >return
>> > error code of 2 (access denied).
>> >
>> > Now I take it that the access denied is to the \\.\root\CIMV2, but how
>> > can
>> > I
>> > verify this?
>> >
>> > I get the same error whether using impersonationlevel=impersonate or
>> > removing that.
>> >
>> > Any help would be appreciated.
>>
>> You don't usually need WMI to launch an application - the exec or run
>> methods of the WScript.Shell object will easily do it for you. Anyway -
>> let's have a look at your script.
>>
>>
>>

My System SpecsSystem Spec
Old 11-17-2008   #7 (permalink)
Joe


 
 

Re: WMI Error 2

Thank you.

The code does run on a non hardened laptop, but not a hardened one.

So I guess it is back to permissions in root/CIMv2 where the Access Denied
is showing up.

"Pegasus (MVP)" wrote:
Quote:

> I forgot to mention in my previous reply that I ran your code on my machine
> without any problems. If you insist on using WMI to invoke external
> applications then you might consider the simple code below:
> strComputer = "."
> Set objWMIService = GetObject _
> ("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
> Err = objWMIService.Create("Notepaad.exe", Null, Null, intProcessID)
>
> It comes from here:
> http://www.microsoft.com/technet/scr...7/hey0426.mspx
>
>
> "Joe" <Joe@xxxxxx> wrote in message
> news:5E2E0835-4587-4AD4-B153-06D3093F78C1@xxxxxx
Quote:

> > Script is attached. It is a simple sample program, but it is the basis
> > for
> > the script
> > that we are planning on using.
> >
> > Const HIDDEN_WINDOW = 0
> > strComputer = "."
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate}!\\" _
> > & strComputer & "\root\cimv2")
> > Set objStartup = objWMIService.Get("Win32_ProcessStartup")
> > Set objConfig = objStartup.SpawnInstance_
> > objConfig.ShowWindow = HIDDEN_WINDOW
> > Set objProcess = GetObject( _
> > "winmgmts:root\cimv2:Win32_Process")
> > errReturn = objProcess.Create( _
> > "notepad.exe", null, objConfig, intProcessID)
> > wscript.echo errReturn
> >
> > "Pegasus (MVP)" wrote:
> >
Quote:

> >>
> >> "Joe" <Joe@xxxxxx> wrote in message
> >> news:7FD36CEF-FD36-4DB4-B3A0-BD5C6FF4072A@xxxxxx
> >> >I am running a VBScript to start an application and I am getting a
> >> >return
> >> > error code of 2 (access denied).
> >> >
> >> > Now I take it that the access denied is to the \\.\root\CIMV2, but how
> >> > can
> >> > I
> >> > verify this?
> >> >
> >> > I get the same error whether using impersonationlevel=impersonate or
> >> > removing that.
> >> >
> >> > Any help would be appreciated.
> >>
> >> You don't usually need WMI to launch an application - the exec or run
> >> methods of the WScript.Shell object will easily do it for you. Anyway -
> >> let's have a look at your script.
> >>
> >>
> >>
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Help with windows vista mail, Socket Error: 10053, Error Number: 0x800CCC0F Vista mail
no,socket Error: 11003. Error Number: 0x800CC0D cant i send email name is correctly Vista mail
Canot post to newsgroups Socket Error: 10053, Error Number: 0x800CCC0F Vista mail
Canot post to newsgroups Socket Error: 10053, Error Number: 0x800CCC0F Vista General
windows live mail 2008 (Build 12.0.1606) error report error Windows Live


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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