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
386 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 51

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 51

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
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.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now