From: Leon on
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
From: urkec on
"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=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
From: Leon on
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...(a)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 -