System.util.execute in 32 bit and 64 bit

I am trying to have a button call a PDF file. The button works in 32 bit version but not in 64 bit. Some
of the OS are Win 7 and others are Vista. Is there a way to detect where Adobe is installed and call the right command.

Here is the script I use:
system.util.execute([“C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe”, “”, “”, “”, “G:\Production\LOGIST’S\PRODUCTI\current schedule.pdf”])

Windows 7 enterprise
C:\Program Files (x86)\Adobe\Reader 11.0\Reader

Vista
C:\Program Files\Adobe\Reader 11.0\Reader

Adobe would have to be installed in the same location on each computer. You could install Adobe on the 64 bit and 32 bit computers using something other than the default location. If you installed to C: then they should have identical file paths. There really isn’t a way for you to get around the “(x86)” part of the filepath.

Use system.file.fileExists to figure out where it is on a given system, then call system.util.execute with the correct path.

Or…

get the OS and select path accordingly

osName = java.lang.System.getProperty(“os.name”)
osVersion = java.lang.System.getProperty(“os.version”)

if osVersion == ‘6.0’: # Vista
system.util.execute([put Vista path here])
elif osVersion == ‘6.1’: # Windows 7
system.util.execute([put Win 7 (x86) path here])
else: # not recognized
system.gui.errorBox(‘OS path error, unrecognized OS Version %s %s’ % (osName,osVersion),‘OS Version Path Error’)

[quote=“markdobtech”]Or…

get the OS and select path accordingly

osName = java.lang.System.getProperty(“os.name”)
osVersion = java.lang.System.getProperty(“os.version”)

if osVersion == ‘6.0’: # Vista
system.util.execute([put Vista path here])
elif osVersion == ‘6.1’: # Windows 7
system.util.execute([put Win 7 (x86) path here])
else: # not recognized
system.gui.errorBox(‘OS path error, unrecognized OS Version %s %s’ % (osName,osVersion),‘OS Version Path Error’)[/quote]

Could you also add

osArch = java.lang.System.getProperty(“os.arch”)

and get x86 vs X64?

Thanks for the tip btw, I figured there was a better way but hadn’t figured it out yet,

Try system.net.openURL()

[quote=“Dravik”]
Could you also add

osArch = java.lang.System.getProperty(“os.arch”)

and get x86 vs X64?

Thanks for the tip btw, I figured there was a better way but hadn’t figured it out yet,[/quote]

osArch will give it for the JVM, not necessarily the OS.

I like the openUrl option, as long as the file associations are valid.

Lemme think a moment…

Aha! the getenv method will look at system variables. We can tell if the %ProgramFiles(x86)% variable is set (i.e. that it’s a 64-bit OS). Throwing it all together with markdobtech’s code and the OPs’ paths, we get this:

[code]import java.lang.System
osName = java.lang.System.getProperty(“os.name”)

if osName[0:3]==“Win”:
if java.lang.System.getenv(“ProgramFiles(x86)”) is None:
programFilesPath = “Program Files”
else:
programFilesPath = “Program Files (x86)”

pathToAdobe=“C:\”+programFilesPath+"\Adobe\Reader 11.0\Reader\AcroRd32.exe"

system.util.execute([pathToAdobe, “”, “”, “”, “G:\Production\LOGIST’S\PRODUCTI\current schedule.pdf”])

else:
system.gui.errorBox(‘OS path error, unrecognized OS Version %s’ % (osName),‘OS Version Path Error’)[/code]

Thanks all. Markdobtech’s solution works great. No issues with opening the file.