![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Monitor content of a specific file every 2 seconds Hi Group Is there a way to manipulate Windows standard scheduler to run a script every 2' second? The script is reading a file only containing a "flag" 1 or 0. Cheers |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Monitor content of a specific file every 2 seconds Hi, Quote: > Is there a way to manipulate Windows standard scheduler to run a > script every 2' second? > > The script is reading a file only containing a "flag" 1 or 0. i think it should be even easier to take one script sleeping for two secconds.. wscript.sleep 2000 regards Dirk |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Monitor content of a specific file every 2 seconds "Leon" <kim.zethsen@xxxxxx> wrote in message news:62eaa25a-1a56-4a87-88d4-0b963e8ebe41@xxxxxx Quote: > Hi Group > > Is there a way to manipulate Windows standard scheduler to run a > script every 2' second? > > The script is reading a file only containing a "flag" 1 or 0. > > Cheers overheads in getting it to run a task once every 2 seconds are possibly prohibitive), but you could use this method: How Can I Check Every 30 Minutes to See If a File Has Been Modified? http://www.microsoft.com/technet/scr...7/hey0723.mspx |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Monitor content of a specific file every 2 seconds On 5 Feb., 22:42, "Dirk Stegemann" <dsgra...@xxxxxx> wrote: Quote: > Hi, > Quote: > > Is there a way to manipulate Windows standard scheduler to run a > > script every 2' second? Quote: > > The script is reading a file only containing a "flag" 1 or 0. > i think it should be even easier to take one script sleeping for two secconds.. > > wscript.sleep 2000 > > regards Dirk I have thought about monitoring like the code hereunder (I really am new in this) which are just monitoring new files... But you are tight that sounds much more simple. ************************************************************************************ strComputer = "." 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=""c:\\\\scripts""'") Do Set objLatestEvent = colMonitoredEvents.NextEvent Wscript.Echo objLatestEvent.TargetInstance.PartComponent Loop ************************************************************************************ Thanks Dirk :-) |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Monitor content of a specific file every 2 seconds Leon wrote: Quote: > Hi Group > > Is there a way to manipulate Windows standard scheduler to run a > script every 2' second? > > The script is reading a file only containing a "flag" 1 or 0. What exactly does the script do besides read a flag file? More information is essentially necessary. -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages) |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Monitor content of a specific file every 2 seconds On 5 Feb., 22:44, "Pegasus \(MVP\)" <I....@xxxxxx> wrote: Quote: > "Leon" <kim.zeth...@xxxxxx> wrote in message > > news:62eaa25a-1a56-4a87-88d4-0b963e8ebe41@xxxxxx > Quote: > > Hi Group Quote: > > Is there a way to manipulate Windows standard scheduler to run a > > script every 2' second? Quote: > > The script is reading a file only containing a "flag" 1 or 0. Quote: > > Cheers > I don't think you can modify the Task Scheduler to do this (and the > overheads in getting it to run a task once every 2 seconds are possibly > prohibitive), but you could use this method: > How Can I Check Every 30 Minutes to See If a File Has Been Modified? > > http://www.microsoft.com/technet/scr.../qanda/jul07/h... No - the thing is - that another system (online scada) is raising a flag on a specifik event and writes to the file whereafter I have to alert some users at once on that event Cheers |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Monitor content of a specific file every 2 seconds On 5 Feb., 22:51, "Todd Vargo" <tlva...@xxxxxx> wrote: Quote: > Leon wrote: Quote: > > Hi Group Quote: > > Is there a way to manipulate Windows standard scheduler to run a > > script every 2' second? Quote: > > The script is reading a file only containing a "flag" 1 or 0. > Why not just run the script in an endless loop? > What exactly does the script do besides read a flag file? > > More information is essentially necessary. > > -- > Todd Vargo > (Post questions to group only. Remove "z" to email personal messages) I just want to check if the file have been modified an if so read the content. Thats bassically it. Can be done as you mentioned. I also want to name the proces so I can se in it windows task manager under processes. Not only wscript.exe - but something like "monitoring_folder" - just so I can see it and so that a another vbs script (from standard scheduler every minut) can monitor that this is running. |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Monitor content of a specific file every 2 seconds "Leon" <kim.zethsen@xxxxxx> wrote in message news:813a1495-8ac2-42f2-ba06-bab4150322f0@xxxxxx Quote: > On 5 Feb., 22:51, "Todd Vargo" <tlva...@xxxxxx> wrote: Quote: >> Leon wrote: Quote: >> > Hi Group Quote: >> > Is there a way to manipulate Windows standard scheduler to run a >> > script every 2' second? Quote: >> > The script is reading a file only containing a "flag" 1 or 0. >> Why not just run the script in an endless loop? >> What exactly does the script do besides read a flag file? >> >> More information is essentially necessary. >> >> -- >> Todd Vargo >> (Post questions to group only. Remove "z" to email personal messages) > Essentially you're right. > I just want to check if the file have been modified an if so read the > content. Thats bassically it. soon as the flag file is changed by "another system (online scada)". How many users, and how do you need to alert them? /Al Quote: > Can be done as you mentioned. > > I also want to name the proces so I can se in it windows task manager > under processes. > Not only wscript.exe - but something like "monitoring_folder" - just > so I can see it and so that a another vbs script (from standard > scheduler every minut) can monitor that this is running. |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Monitor content of a specific file every 2 seconds Leon <kim.zethsen@xxxxxx> typed: Quote: > I just want to check if the file have been modified an if so read the > content. Thats bassically it. > Can be done as you mentioned. ' MoniFile.vbs Option Explicit Const Archive = 32, ForReading = 1 Dim fso Set fso = CreateObject("Scripting.FileSystemObject") If WScript.Arguments.Count > 0 Then Do While fso.FileExists(WScript.Arguments(0)) With fso.GetFile(WScript.Arguments(0)) If .Attributes And Archive Then With .OpenAsTextStream(ForReading, vbUseDefault) WScript.Echo .ReadAll .Close End With .Attributes = .Attributes Xor Archive End If End With WScript.Sleep 2000 Loop End If Quote: > I also want to name the proces so I can se in it windows task manager > under processes. > Not only wscript.exe - but something like "monitoring_folder" - just > so I can see it and so that a another vbs script (from standard > scheduler every minut) can monitor that this is running. -- ЯR |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Monitor content of a specific file every 2 seconds On 6 Feb., 02:00, "Ruediger Roesler" <administra...@xxxxxx> wrote: Quote: > Leon <kim.zeth...@xxxxxx> typed: > Quote: > > I just want to check if the file have been modified an if so read the > > content. Thats bassically it. > > Can be done as you mentioned. > Try this one (provide the path to the file as the first argument): > > ' MoniFile.vbs > Option Explicit > > Const Archive = 32, ForReading = 1 > Dim fso > > Set fso = CreateObject("Scripting.FileSystemObject") > > If WScript.Arguments.Count > 0 Then > Â* Â* Do While fso.FileExists(WScript.Arguments(0)) > Â* Â* Â* Â* With fso.GetFile(WScript.Arguments(0)) > Â* Â* Â* Â* Â* Â* If .Attributes And Archive Then > Â* Â* Â* Â* Â* Â* Â* Â* With .OpenAsTextStream(ForReading, vbUseDefault) > Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* WScript.Echo .ReadAll > Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* .Close > Â* Â* Â* Â* Â* Â* Â* Â* End With > Â* Â* Â* Â* Â* Â* Â* Â* .Attributes = .Attributes Xor Archive > Â* Â* Â* Â* Â* Â* End If > Â* Â* Â* Â* End With > Â* Â* Â* Â* WScript.Sleep 2000 > Â* Â* Loop > End If > Quote: > > I also want to name the proces so I can se in it windows task manager > > under processes. > > Not only wscript.exe - but something like "monitoring_folder" - just > > so I can see it and so that a another vbs script (from standard > > scheduler every minut) can monitor that this is running. > Don't know, sorry. > > -- > ЯR Have a nice weekend Leon |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Set specific apps to work on secondary monitor? | General Discussion | |||
| Internet Explorer Content Advisor - Allow or Block Specific Websites | Tutorials | |||
| Set-Content not updating file after get-content and forEach-Object | PowerShell | |||
| About adding content to the same file using "add-content" | PowerShell | |||
| Weirdness with get-content | replace | set-content - file content is deleted!! | PowerShell | |||