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
392 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 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

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…
On some Windows 7 (SP1) computers, Windows Update becomes super slow even the computer is reasonably fast.  There's one solution that seemed to have worked well for me (after trying a few other suggested solutions).
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

735 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