Avatar of Bob Stamm
Bob Stamm
Flag 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
Microsoft Development.NET Programming

Avatar of undefined
Last Comment
Bob Stamm

8/22/2022 - Mon
motnahp00

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
Bob Stamm

ASKER
Will this place the files in either the Program Files or Program Files(86) depending on the  user?
motnahp00

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
John

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
Bob Stamm

ASKER
Not easily to change location.  I have ~ 80 users in our company setup.  Only a few have been updated to Windows 7.
motnahp00

Does each user require a unique copy of the database for their own profile?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
John

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
Ian Pattison

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Bob Stamm

ASKER
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
Ian Pattison

No more comments, are we to assume it's working?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Bob Stamm

ASKER
Solution put me on right path.  I posted my final version specific to my needs.

Thanks,
Bob