Solved

Simple file copy login script based on time and date stamp

Posted on 2009-04-09
3
601 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 14

Expert Comment

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

date last modified ? access ? created ?
0
 
LVL 84

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Button function on table is in trouble 3 39
save excel in the same active file's folder. 8 48
Import CSV with All modify groups 17 82
msiexec won't run 4 15
Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
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…

738 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