Solved

Anyone out there?  How would i write a dos batch script that would branch based on OS? windows xp vs vista, 7, 8?

Posted on 2013-12-07
4
391 Views
Last Modified: 2013-12-07
I need to call an app that will be in:

c:\program files

for xp

and for vista, 7 and 8, it would be C:\Program Files (x86)

I am tempted to just include both lines - 1 would fail, and the other would work, but that's 'cheating'.

the dos commands to do this:
=====
if os=xp goto xpcommand

 C:\Program Files (x86)\.......
goto end

:xpcommand
C:\Program Files\......

:end
===============

I just need that first line?  any help?
0
Comment
  • 2
4 Comments
 
LVL 53

Accepted Solution

by:
Joe Winograd, EE MVE earned 500 total points
ID: 39703870
The answer is in this thread:

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/Windows_7/Q_28201357.html

Notice my addition after the question was closed that adds the check for W8. Regards, Joe
0
 

Author Comment

by:BeGentleWithMe-INeedHelp
ID: 39703880
Thanks!  You didn't get the points for that one, you got them now : )
0
 
LVL 53

Expert Comment

by:Joe Winograd, EE MVE
ID: 39703884
Yes, thank you for that! I'm glad that thread stuck in my brain. :)
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 39703974
I shluld probably have just point out the obvious, windows 7will uses program files too, and xp program files (x86), i.e. it is the 32/64 os version that matters.

various corporates especially still run 32 bit Windows 7 on 64 bit machines  etc. and you do come across (though less so) 64 bit XP machines.

the simple answer then is to check the environment variables, or the existence of the directory structure, e.g.

if exist "%windir%\syswow64\notepad.exe" (
 echo on 64 bit m achine
 set dest=program files(x86)
 ) else (
 echo on 32 bit machine
 set dest=program files
)

best I can do from phone!

Steve
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

829 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