We help IT Professionals succeed at work.


Last Modified: 2012-05-05
I have scripts that run on Win2K/WinXP/win23k/winvista machines 32bit OS  i.e "if exist "c:\programs files\ntp\ntp.exe" do xcopy "\\filesrv2\time server\ntp.conf" "c:\program files\etc\" It runs great with no problem.

I have recently introduced Windows Vista 64bit. The default install location for the ntp program is now
c:\program files(x86)\ntp\ntp.exe

I want a syntax that will work for 32 bit  and 64bit OS.

i.e. script checks both locations and then run it
c:\program files(x86)\ntp\ntp.exe
c:\programs files\ntp\ntp.exe
Watch Question

Top Expert 2007

How about using ProgramFiles?
if exist "%ProgramFiles%\ntp\ntp.exe" do xcopy "\\filesrv2\time server\ntp.conf" "%ProgramFiles%\etc\" 

Open in new window


I know the ~ character works in XP so maybe try copying to c:\progra~1\ntp\ntp.exe
This one is on us!
(Get your first solution completely free - no credit card required)

I forgot to tell you that save the above batch script as .Bat file and run it.

Keyword "DO" is not recognized as any command in DOS. I think you have used it to just explain what you want to do.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.