[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming.threads

I invite you to listen to this beautiful french song

Ramine

12/4/2014 3:31:00 AM

Hello...


I invite you to listen to this beautiful french song, cause
i speak mainly in french in real life...


https://www.youtube.com/watch?v=iW-t_T_eLO4&s...



Thank you,
Amine Moulay Ramdane.
3 Answers

Ruediger Roesler

2/6/2009 1:01:00 AM

0

Leon <kim.zethsen@gmail.com> typed:

> 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

> 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

Todd Vargo

2/6/2009 11:06:00 PM

0

Leon wrote:
> 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.

I don't know how to change the name of the process but I do know how to set
it to what I want. For me in Winodws 98, I just make a copy of wscript.exe
and rename it to whatever I want it to display. For example, you might copy
wscript.exe to monitoring_folder.exe. I have not tried this in XP to see if
it works for XP too.

The following script may do what you want. I included a mechanism to prevent
accidentally starting another instance. To run it, create a shortcut with,

monitoring_folder.exe FileMonitor.vbs

as the target or command line. Each time the flag file changes, a popup will
notify you (in lieu of an email). The popup also serves as a mechanism to
abort the script during your testing. You can remove it if you want the
script to run in an endless loop.


' FileMonitor.vbs
' This script includes a mechanism that prevents
' running multiple instances of itself.

Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

' ==== Initialize single instance mechanism ====
tmp = fso.GetSpecialFolder(2) 'Get TEMP folder
tmp = tmp & ".\" & WScript.ScriptName & ".running"

On Error Resume Next
fso.DeleteFile(tmp) 'Remove any orphaned zero byte file
On Error Goto 0

If fso.FileExists(tmp) Then
WshShell.Popup WScript.ScriptFullName & _
" is already running!",2,"Oops...",48
WScript.Quit
Else
'Create a zero byte file in TEMP.
Set zbf = fso.OpenTextFile(tmp, 2, True)
End If
' ==== Single instance test complete ====

MonitorFile "flag.txt" ' <=== The file to monitor goes here

' ==== Clean up zero byte file ====
zbf.Close
fso.DeleteFile(tmp)
Wscript.Quit

Sub MonitorFile(flagfile)
If Not fso.FileExists(flagfile) Then
MsgBox flagfile & " does not exist.",vbCritical, _
WScript.ScriptFullName
Exit Sub
End If
Set f = fso.GetFile(flagfile)
DateLastModified = f.DateLastModified

Do
checkit = f.DateLastModified
If DateLastModified <> checkit Then
BtnCode = WshShell.Popup("Do you want to abort?", _
2, "FILE CHANGED", 36)
If BtnCode = vbYes Then Exit Do
DateLastModified = checkit
' Put code to send email (or whatever) here.
Else
Wscript.Sleep 2000
End If
Loop
End Sub


--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Python

2/12/2009 12:32:00 AM

0

Check for a post by me in an earlier thread containg the words "adtempus" or
"PA Server Monitor Pro". Because you mention scada (I am assuming
Supervisory Control And Data Acquisition) that you are working in an
environment that probably has a few spare dollars floating around in the
budget. Adtempus is an advanced job scheduler that incorporates file and
folder watch as two of the possible task triggers. The price is reasonable
and we used this software as the core of a complex scheduling system which
also interfaced to many data feeds from our Scada system.

PA Server Monitor Pro can also be used as a robust system monitoring tool
that also supports many triggers including file watch. I highly recommend
both packages.