Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing an Application using WSH/VBScipt

Status
Not open for further replies.

Kimara

Programmer
Jul 30, 2002
2
GB
Hiya Folks

if anyone could answer my question, it would be really wonderful as I have spent alot of time trying to solve this one.

The following script compares 2 files, and if the file on the CD is more recent then the one on the hard drive it updates the hard drive file to the latest version.

Function Update( source, target)

Dim f1,f2,d1,d2,c1,c2,m1

if fs.FileExists( source ) then
set f1 = fs.GetFile( source )

d1 = f1.DateLastModified
c1 = Year(d1) * 10000 + Month(d1) * 100 + Day(d1)

if fs.FileExists( target ) then
set f2 = fs.GetFile( target )
d2 = f2.DateLastModified
c2 = Year(d2) * 10000 + Month(d2) * 100 + Day(d2)
else
c2 = 0
end if

if c1 > c2 then
f1.Copy target,True
MsgBox("New file found and update completed")
end if
end if

End Function


Dim fs
set fs = WScript.CreateObject("Scripting.FileSystemObject")

s = "C:\main.exe"
t = "C:\BB\main.exe"

update s, t

What is happening is that this script is run every 30 secs in a Flash projector to check for new files, if it finds one it updates the old one...so far so good.

However whilst it is checking every 30 secs for an update, the flash production 'main.exe' on the hard drive is already playing, so I need to be able to close the application 'main.exe' if the script finds an update, and then run the new and updated version of 'main.exe' which has now been copied from the CD to the hard drive.

Has anyone PLEASE got any ideas at all, as I seem to be going around and around in circles.

All input GRATEFULLY accepted.
Yours

Kimara
 
Thanks for your reply, I tried it and it worked fine, only trouble is the client has decided to use Win 98 SE on the client machines so the script won't work.

Thanks for your help anyway, the script you showed me will come in useful somewhere for sure.
Anybody have any other ideas ? even if it means running a VB or C++ mod/app to just close down the main.exe file befor updating it and re launching it...its only the closing down the application bit I am stuck on, as I cannot update the file while its running as its locked..

Anyhelp wil be greatly APPRECIATED..

Cheers folks

Kimara
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top