batch file that opens IE based on 32bit or 64bit OS
Any batch file guru's out there? I'm in a situation where I have 32bit and 64bit versions of Windows 7 in production. The users will run this batch file which will link to one of our online systems. So I need this file to open IE whether they are running 32bit or 64bit. Note that IE 32bit is required for this to work. Here is what I have so far, but doesnt seem to work. @echo off IF EXISTS %Program Files (x86)% "%Program Files (x86)%\Internet Explorer\IEXPLORE.EXE" http://www.google.com ELSE "%Program Files%\Internet Explorer\IEXPLORE.EXE" http://www.google.com I'm getting this error - "The syntax of the command is incorrect." Any ideas?
April 21st, 2010 12:53am

Hi, Please try this: IF EXIST %Program Files (x86)% ( "%Program Files (x86)%\Internet Explorer\IEXPLORE.EXE" http://www.google.com ) ELSE ( "%Program Files%\Internet Explorer\IEXPLORE.EXE" http://www.google.com ) Please verify if the environment variables %Program Files (x86)% and %Program Files% exist (in my 32-bit client, I can see a %ProgramFiles% environment variable [without the space]). Regards, Salvador Manaois III MCSE MCSA MCTS MCITP:EA/SA C|EH CIWA ---------------------------------------------------------------------------- Bytes & Badz: http://badzmanaois.blogspot.com My Passion: http://flickr.com/photos/badzmanaois My Scripting Blog: http://sgwindowsgroup.org/blogs/badz
Free Windows Admin Tool Kit Click here and download it now
April 21st, 2010 1:39am

Yes you are correct, I think that's where I was going wrong. The environment variables do not have a space. IF EXIST %ProgramFiles(x86)% ( "%ProgramFiles(x86)%\Internet Explorer\IEXPLORE.EXE" http://www.google.com ) ELSE ( "%ProgramFiles%\Internet Explorer\IEXPLORE.EXE" http://www.google.com ) Do you know how to get it to stop or end after the first statement. After the browser is closed, it will then open up the ELSE part. Thanks!
April 21st, 2010 1:55am

Hi, If it goes to execute the first call for IE, it will never go into the ELSE part (even after you close the invoked browser) based on the logic of the script. What you can do if you want the ELSE part to execute is to move the clause inside the ELSE statement into the first clause (I'm not sure if this is what you really want though): IF EXIST %ProgramFiles(x86)% "%ProgramFiles(x86)%\Internet Explorer\IEXPLORE.EXE" http://www.google.com "%ProgramFiles%\Internet Explorer\IEXPLORE.EXE" http://www.google.com ) ELSE ( REM Do something else here ) Regards, Salvador Manaois III MCSE MCSA MCTS MCITP:EA/SA C|EH CIWA ---------------------------------------------------------------------------- Bytes & Badz: http://badzmanaois.blogspot.com My Passion: http://flickr.com/photos/badzmanaois My Scripting Blog: http://sgwindowsgroup.org/blogs/badz
Free Windows Admin Tool Kit Click here and download it now
April 21st, 2010 2:04am

That's what it seems to be doing. I will open IE based on the first part. When I close IE, it open's IE again. I think it's b/c win7 64bit has both of those diretories; Being that it has a 32bit and 64bit version of IE. But I see what you're saying. I thought it would end too but it didnt. Try it, thats what it does for me.
April 21st, 2010 2:50am

Figured out why it was doing that. Here's the end result... IF EXIST "%ProgramFiles(x86)%" ( "%ProgramFiles(x86)%\Internet Explorer\IEXPLORE.EXE" http://www.google.com ) ELSE ( "%ProgramFiles%\Internet Explorer\IEXPLORE.EXE" http://www.google.com ) In the line: IF EXIST %ProgramFiles(x86)%, quotes needed to be around the variable in order for it to run correctly.
Free Windows Admin Tool Kit Click here and download it now
April 21st, 2010 6:21pm

Thank you for sharing the solution. If you have more questions in the future, you’re welcomed to this forum. RegardsThis posting is provided "AS IS" with no warranties, and confers no rights.
April 23rd, 2010 1:31pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics