Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

access denied getobject

43 views
Skip to first unread message

Leon

unread,
Dec 21, 2009, 9:04:01 AM12/21/09
to
Hi

I want to monitor a folder on a remote server with this littlæe
script.
But - access denied.. How do I put in user and password?

strComputer = "remoteserver"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceCreationEvent WITHIN 0.1 WHERE " _
& "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
& "TargetInstance.GroupComponent= " _
& "'Win32_Directory.Name=""e:\\\\Temp""'")
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo objLatestEvent.TargetInstance.PartComponent
Loop

urkec

unread,
Dec 21, 2009, 11:18:01 AM12/21/09
to
"Leon" wrote:

> .
>


Use SWbemLoactor to connect to thhe remote computer:


http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.scripting.vbscript&cat=en_US_8e0bf598-2567-4b0b-8241-d4942bda87dc&lang=en&cr=US

You can find an example at the bottom of the page.

--
urkec

Leon

unread,
Dec 22, 2009, 6:26:28 PM12/22/09
to
Hi

Thanks for the answer - but no access rights..
Then - I found out that mapping up the remote PC to a drive letter did
solve the case.

Cheers

On 21 Dec., 17:18, urkec <ur...@discussions.microsoft.com> wrote:
> "Leon" wrote:
> > Hi
>
> > I want to monitor a folder on a remote server with this littlæe
> > script.
> > But - access denied.. How do I put in user and password?
>
> > strComputer = "remoteserver"
> > Set objWMIService = GetObject("winmgmts:" _
> >     & "{impersonationLevel=impersonate}!\\" & _
> >         strComputer & "\root\cimv2")
> > Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
> >     ("SELECT * FROM __InstanceCreationEvent WITHIN 0.1 WHERE " _
> >         & "Targetinstance ISA 'CIM_DirectoryContainsFile' and " _
> >             & "TargetInstance.GroupComponent= " _
> >                 & "'Win32_Directory.Name=""e:\\\\Temp""'")
> > Do
> >     Set objLatestEvent = colMonitoredEvents.NextEvent
> >     Wscript.Echo objLatestEvent.TargetInstance.PartComponent
> > Loop
> > .
>
> Use SWbemLoactor to connect to thhe remote computer:
>

> http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg...


>
> You can find an example at the bottom of the page.
>
> --

> urkec- Skjul tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -

0 new messages