MAJOR NEWBIE -check file timedatestamp in batch - MS-DOS v VBScript 
Author Message
 MAJOR NEWBIE -check file timedatestamp in batch - MS-DOS v VBScript

I have done some MS-DOS batch programming and some Access VBA programming,
but I need help here...

I need to write a batch/script file to....
   check a the filecreated timedate stamp on a local file
   and compare it to the same filename on another machine on the network (a
server).
   If the network server version is younger,
   copy it over the local file.

Thought about trying to use MS-DOS command programming....
dir output to a text file, comparing for both....  OR
writing a util in C.......

But I think VBScript will be preferable.
I found this snippet at
http://www.*-*-*.com/
that looks real promising....

Function ShowDateCreated(filespec)
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(filespec)
   ShowDateCreated = f.DateCreated
End Function

BUT how do I start ?

Load Notepad, write VBScript, save as UPDATE.vbs?
create a UPDATE.wsh ? to point to it ?
run it on the command line with...... Cscript UPDATE.vbs ?

If anyone has seen a script that done this type of thing,
or has *any* input,   THANK  YOU !



Sat, 05 Jul 2003 22:15:24 GMT  
 MAJOR NEWBIE -check file timedatestamp in batch - MS-DOS v VBScript
Script file are just text files so any text editor will do.  Save you script with a .vbs extension.
You can execute it by double clicking it in Windows Explorer.

Start with the WSH 2.0 Tutorial and "...User's Guide" links.

The EXE links below are downloads of the complete documentation sets in HTMLHelp format - highly
recommended for offline use.  The Tutorial and "...User's Guide" content is also included in the
downloaded documentation...

WSH 2.0 Tutorial
http://msdn.microsoft.com/scripting/windowshost/doc/wsTutorialTOC.htm
WSH Documentation
http://msdn.microsoft.com/scripting/windowshost/docs/reference/defaul...
http://msdn.microsoft.com/scripting/windowshost/wshdoc.exe

VBScript User's Guide
http://msdn.microsoft.com/scripting/vbscript/doc/vbstutor.htm
VBScript Documentation
http://msdn.microsoft.com/scripting/vbscript/techinfo/vbsdocs.htm
http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe

FileSystemObject User's Guide
http://msdn.microsoft.com/scripting/vbscript/doc/jsFSOTutor.htm
VBScript Run-Time Library Reference [FileSystemObject/Dictionary]
http://msdn.microsoft.com/scripting/vbscript/doc/VBSFSOTOC.htm

JScript User's Guide
http://msdn.microsoft.com/scripting/jscript/doc/jsconJScriptUsersGuid...
JScript Documentation
http://msdn.microsoft.com/scripting/jscript/techinfo/jsdocs.htm
http://msdn.microsoft.com/scripting/jscript/download/jsdoc.exe

WSC Tutorial
http://msdn.microsoft.com/scripting/scriptlets/doc/lettitle.htm
WSC Documentation
http://msdn.microsoft.com/scripting/scriptlets/serverdocs.htm
http://msdn.microsoft.com/scripting/scriptlets/wscdoc.exe

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> I have done some MS-DOS batch programming and some Access VBA programming,
> but I need help here...

> I need to write a batch/script file to....
>    check a the filecreated timedate stamp on a local file
>    and compare it to the same filename on another machine on the network (a
> server).
>    If the network server version is younger,
>    copy it over the local file.

> Thought about trying to use MS-DOS command programming....
> dir output to a text file, comparing for both....  OR
> writing a util in C.......

> But I think VBScript will be preferable.
> I found this snippet at
> http://msdn.microsoft.com/scripting/default.htm?/scripting/start.htm
> that looks real promising....

> Function ShowDateCreated(filespec)
>    Dim fso, f
>    Set fso = CreateObject("Scripting.FileSystemObject")
>    Set f = fso.GetFile(filespec)
>    ShowDateCreated = f.DateCreated
> End Function

> BUT how do I start ?

> Load Notepad, write VBScript, save as UPDATE.vbs?
> create a UPDATE.wsh ? to point to it ?
> run it on the command line with...... Cscript UPDATE.vbs ?

> If anyone has seen a script that done this type of thing,
> or has *any* input,   THANK  YOU !



Sun, 06 Jul 2003 10:43:20 GMT  
 MAJOR NEWBIE -check file timedatestamp in batch - MS-DOS v VBScript
This is the solution I worked out,
 any comments, caveats? ....

'
'
'  save as...
'  upstuff.vbs
'
'  run in batch as...
'  C:\>cscript upstuff.vbs
'
'
'
Dim file1
Dim file2

Dim f1dt
Dim f2dt

Dim status

file1 = "C:\stuff.exe"
file2 = "\\server\stuff.exe"

f1dt=ShowDateCreated(file1)
f2dt=ShowDateCreated(file2)

status ="You do not need an update !"
If f2dt > f1dt Then status ="...Updating..."

msgbox file1 & " created  " & f1dt & vbNewLine & vbNewLine _
& file2 & " created  " & f2dt  _
& vbNewLine & vbNewLine & status

If f2dt > f1dt Then Call UpdateStuffCopy(file2)

Function ShowDateCreated(filespec)
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(filespec)
   ShowDateCreated = f.DateCreated
End Function

Sub UpdateStuffCopy(file2)
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFile(file2)
   f.Copy ("C:\stuff.exe")
End Sub


Quote:
> I have done some MS-DOS batch programming and some Access VBA programming,
> but I need help here...

> I need to write a batch/script file to....
>    check a the filecreated timedate stamp on a local file
>    and compare it to the same filename on another machine on the network
(a
> server).
>    If the network server version is younger,
>    copy it over the local file.

> Thought about trying to use MS-DOS command programming....
> dir output to a text file, comparing for both....  OR
> writing a util in C.......

> But I think VBScript will be preferable.
> I found this snippet at
> http://msdn.microsoft.com/scripting/default.htm?/scripting/start.htm
> that looks real promising....

> Function ShowDateCreated(filespec)
>    Dim fso, f
>    Set fso = CreateObject("Scripting.FileSystemObject")
>    Set f = fso.GetFile(filespec)
>    ShowDateCreated = f.DateCreated
> End Function

> BUT how do I start ?

> Load Notepad, write VBScript, save as UPDATE.vbs?
> create a UPDATE.wsh ? to point to it ?
> run it on the command line with...... Cscript UPDATE.vbs ?

> If anyone has seen a script that done this type of thing,
> or has *any* input,   THANK  YOU !




Quote:
> Script file are just text files so any text editor will do.  Save you

script with a .vbs extension.
Quote:
> You can execute it by double clicking it in Windows Explorer.

> Start with the WSH 2.0 Tutorial and "...User's Guide" links.

> The EXE links below are downloads of the complete documentation sets in

HTMLHelp format - highly
Quote:
> recommended for offline use.  The Tutorial and "...User's Guide" content

is also included in the

- Show quoted text -

Quote:
> downloaded documentation...

> WSH 2.0 Tutorial
> http://msdn.microsoft.com/scripting/windowshost/doc/wsTutorialTOC.htm
> WSH Documentation
> http://msdn.microsoft.com/scripting/windowshost/docs/reference/defaul...
> http://msdn.microsoft.com/scripting/windowshost/wshdoc.exe

> VBScript User's Guide
> http://msdn.microsoft.com/scripting/vbscript/doc/vbstutor.htm
> VBScript Documentation
> http://msdn.microsoft.com/scripting/vbscript/techinfo/vbsdocs.htm
> http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe

> FileSystemObject User's Guide
> http://msdn.microsoft.com/scripting/vbscript/doc/jsFSOTutor.htm
> VBScript Run-Time Library Reference [FileSystemObject/Dictionary]
> http://msdn.microsoft.com/scripting/vbscript/doc/VBSFSOTOC.htm

> JScript User's Guide
> http://msdn.microsoft.com/scripting/jscript/doc/jsconJScriptUsersGuid...
> JScript Documentation
> http://msdn.microsoft.com/scripting/jscript/techinfo/jsdocs.htm
> http://msdn.microsoft.com/scripting/jscript/download/jsdoc.exe

> WSC Tutorial
> http://msdn.microsoft.com/scripting/scriptlets/doc/lettitle.htm
> WSC Documentation
> http://msdn.microsoft.com/scripting/scriptlets/serverdocs.htm
> http://msdn.microsoft.com/scripting/scriptlets/wscdoc.exe

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --

> Please do not email questions - post them to the newsgroup instead.
> --




- Show quoted text -

Quote:
> > I have done some MS-DOS batch programming and some Access VBA
programming,
> > but I need help here...

> > I need to write a batch/script file to....
> >    check a the filecreated timedate stamp on a local file
> >    and compare it to the same filename on another machine on the network
(a
> > server).
> >    If the network server version is younger,
> >    copy it over the local file.

> > Thought about trying to use MS-DOS command programming....
> > dir output to a text file, comparing for both....  OR
> > writing a util in C.......

> > But I think VBScript will be preferable.
> > I found this snippet at
> > http://msdn.microsoft.com/scripting/default.htm?/scripting/start.htm
> > that looks real promising....

> > Function ShowDateCreated(filespec)
> >    Dim fso, f
> >    Set fso = CreateObject("Scripting.FileSystemObject")
> >    Set f = fso.GetFile(filespec)
> >    ShowDateCreated = f.DateCreated
> > End Function

> > BUT how do I start ?

> > Load Notepad, write VBScript, save as UPDATE.vbs?
> > create a UPDATE.wsh ? to point to it ?
> > run it on the command line with...... Cscript UPDATE.vbs ?

> > If anyone has seen a script that done this type of thing,
> > or has *any* input,   THANK  YOU !



Sun, 06 Jul 2003 21:03:20 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to open my local MS-DOS batch file

2. How to open my local MS-DOS batch file

3. dos batch files & VBscripts

4. VBScript and MSDOS Batch files.

5. ??? Is a DOS Batch File Better ???

6. Writing international chars to a DOS batch file

7. Call VBScribt with parameter from DOS Batch file

8. Pass Javascript variable to DOS Batch File

9. ??? Is a DOS Batch File Better ???

10. Hiding the cmd (Dos) windows in Batch file

11. Running dos commands, batch files

12. PostScript files viewer for MS-DOS

 

 
Powered by phpBB® Forum Software