Link to home
Start Free TrialLog in
Avatar of Bob Stamm
Bob StammFlag for United States of America

asked on

Batch file - Window 7 Help

Experts,
I have users now with Windows XP and Window 7.  Need help to write this batch program for users to copy file in "Program Files or Program Files(86).  

Below is my current batch file.

Thanks,
Bob

rem '
copy "\\agc01.com\agc-crp\crpglobal\everyone\NewFrontEnd\ConstructionDatabase.mde" "c:\Program Files\AGOC\ConstructionDatabase\"
@ echo off
pause
Avatar of motnahp00
motnahp00
Flag of United States of America image

I have another suggestion.

Use robocopy instead. It's faster and detects file level changes at a directory level.

I would map your drive letter first:

net use Z: \\agc01.com\agc-crp\crpglobal\everyone\NewFrontEnd

robocopy "Z:\agc01.com\agc-crp\crpglobal\everyone\NewFrontEnd" c:\Program Files\AGOC\ConstructionDatabase" /MIR /R:0

Make sure you test the destination path with something like this before you implement as a production script:

robocopy "Z:\agc01.com\agc-crp\crpglobal\everyone\NewFrontEnd" c:\test" /MIR /R:0
Avatar of Bob Stamm

ASKER

Will this place the files in either the Program Files or Program Files(86) depending on the  user?
It only looks for the source and destination. If you prefer to create a folder within one of the Program Files directory as a destination that is fine.
Windows 7 protects the Program Folders and a copy into these folders will usually result in a UAC permission prompt. That may prevent your batch file from working without intervention.

Can you put your database somewhere else beside Program Folders?

.... Thinkpads_User
Not easily to change location.  I have ~ 80 users in our company setup.  Only a few have been updated to Windows 7.
Does each user require a unique copy of the database for their own profile?
Windows 7 is totally different from XP with respect to Program Folders. Going forward, you will need to deal with this.

In the meantime, Task Scheduler can provide elevated permissions to run programs, so you should look at Task Scheduler.

.... Thinkpads_User
ASKER CERTIFIED SOLUTION
Avatar of Ian Pattison
Ian Pattison
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I made a couple of changes and this seems to work fine. I will award points after I see if there are any additional comments.


@Echo OFF
CLS
Echo Testing...

If exist "c:\Program Files (x86)\*.*" GOTO X86
Echo Found Program Files
REM Files should go in %Program Files% (i.e. 32-bit PC)
copy "\\agc01.com\agc-crp\crpglobal\everyone\NewFrontEnd\ConstructionDatabase.mde" "c:\Program Files\AGOC\ConstructionDatabase\"

GOTO Done

:x86
REM Files should go in %Program Files (x86)% (i.e. 64-bit PC)
Echo Found Program Files (x86)
copy "\\agc01.com\agc-crp\crpglobal\everyone\NewFrontEnd\ConstructionDatabase.mde" "c:\Program Files (x86)\AGOC\ConstructionDatabase\"

:Done
Echo End of Batch File
pause
No more comments, are we to assume it's working?
Solution put me on right path.  I posted my final version specific to my needs.

Thanks,
Bob