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
390 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 52

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 52

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
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…

777 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