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
395 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 54

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 54

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

Increase your protection from Zero Day threats!

Running two Antivirus' is never a good idea.
Taking advantage of Multiple Security layers on the other hand can often save your hide.
See which top notch security software brands have been proven to happily coexist together.
Reduce your chances of becoming a statistic.

Question has a verified solution.

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

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
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…

739 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