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:
You can find an example at the bottom of the page.
--
urkec
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 -