Solved

Simple file copy login script based on time and date stamp

Posted on 2009-04-09
3
596 Views
Last Modified: 2012-05-06
Hi Experts.
Im looking for a simple login script that will copy one file from a unc share on a server to the users local program files directory based on the date and time stamp...
If the file in the share is newer than the one located in the users program files folder than the file is copied over...if it is the same date than the copy command is ignored.

Something like the code below works put i dont know how to do based on checking the date and time stamp.

Thanks for your advice :)
If exist \\server\share\file.txt goto copy

exit

:copy

copy \\server\share\file.txt "c:\program files\vendor\app\file.txt"

exit

Open in new window

0
Comment
Question by:MVDRUM
3 Comments
 
LVL 14

Expert Comment

by:yehudaha
ID: 24113887
what do you mean newer ?

date last modified ? access ? created ?
0
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 24114448
Simply use xcopy with the /d switch; this will copy the file only if it's newer than the destination file.
Your script can be shortened a bit, too.
- always put quotes around paths, whether you need them at the moment or not, just to get used to it; they don't hurt if they're not needed.
- you should use "%ProgramFiles%" instead of hardcoding the program folder name
- No need for "exit" at the end of a batch script, it's just annoying if you're testing a script from the command line and have to re-open the command line all the time. If a batch script is started externally (as logon script, for example), the shell window simply closes when it's finished.

If exist "\\server\share\file.txt" xcopy "\\server\share\file.txt" "%ProgramFiles%\vendor\app\file.txt" /d

Open in new window

0
 

Author Closing Comment

by:MVDRUM
ID: 31568818
Excellent adivice/answer oBdA !
Thanks for the explanations along with the answer !!
Muchly apreciated !
spot on !
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now