Link to home
Start Free TrialLog in
Avatar of alisafia
alisafia

asked on

batch

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
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

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

Open in new window

Avatar of Kutyi
I know the ~ character works in XP so maybe try copying to c:\progra~1\ntp\ntp.exe
ASKER CERTIFIED SOLUTION
Avatar of TheGD
TheGD
Flag of Pakistan 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 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.