CrossOver Support - Community Forums

Important Information These are community forums and not official technical support. If you need official support: Contact Us

CrossOver Mac
Discussion about CrossOver Mac

The following comments are owned by whoever posted them. We are not responsible for them in any way.

Back to Threads Reply to Thread

Run Windows command-line .exe from mac cmd-line?

I've RTFM'd but I can't figure out how to do this - any hints?

I'd like to launch a windows .exe (command-line only, no windows GUI, passing in command-line args and all that) from within a Mac OSX shell script.

It looks like Crossover can do the above from within the Mac Crossover GUI, but that's not quite what I need -- any hints anyone?

Hi, I have the same problem -- I'm writing a script that runs a windows .exe with cmd-line args etc.

Although I have a partial solution via applescript: my script opens CrossOver, selects the "Run Command..." -menu item and pastes the command to the window. This works well, except that I can't receive the return value of the .exe program, which is vital.

Any hints on getting the return value somehow?

To use Crossover in Mac's Terminal, you'll need to use "Open Shell", which is an option you'll find in the Run Command dialog, under "Debug Options". Crossover needs to set a number of environment variables in order to work properly via Mac's terminal.

Once the terminal is populated, you'll generally run commands as such

$ wine --cx-app [applauncher.exe] [arguments]

This assumes that the .exe file in question is located within the bottle's drive_c. If not, you'll need to provide the full file path (or copy the .exe to the bottle's drive_c).

I'd like to run a wine/CrossOver Mac app from within an existing Terminal session, and pass the Windows .exe file a couple of command line arguments as well.

Something like this:

$ run-my-crossover-mac-app arg1 arg2 arg3

Is this possible?

The previous answer uses the "Open Shell" option, which isn't automatic enough for me.

Thanks!

EDIT What follows is incorrect advice, and will almost certainly not work for you. Sorry! See my subsequent post at 2011-06-28 10:51 for more info /EDIT

The 'bare bones' approach would be something like

$ /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wine --cx-app applauncher.exe arg1

Provided that the bottle which contains the applauncher.exe file is set as your default bottle. Otherwise you'll need to

use --bottle "bottle name"

prior to --cx-app

Be advised that you will experience problems with the app by going this route (i.e. by skipping the "open shell" tool). In most cases these will be cosmetic problems - the Environment Variables set in the Open Shell dialog include paths to X11 libraries and other components necessary for proper window management. But, try it and see - if your app is sufficiently "simple" from a graphical perspective, you might not encounter any real difficulties, at all. If you're invoking word 2007, though (or something comparable) most of your GUI buttons will be missing.

Thanks for the suggestion, Jack. I tried it like this:

~ $ /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wine --bottle "Beyond Compare" --cx-app BCompare.exe

and I got this error message:

Can't load '/System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/Mac/Files/Files.bundle' for module Mac::Files: /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/Mac/Files/Files.bundle: no appropriate 64-bit architecture (see "man perl" for running in 32-bit mode) at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/DynaLoader.pm line 207, <DATA> line 1.
at /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/lib/perl/CXBottle.pm line 66
Compilation failed in require at /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/lib/perl/CXBottle.pm line 66, <DATA> line 1.

BCompare.exe is the actual Windows .exe file that launches the program. I can run Beyond Compare from within CrossOver just fine.

It seems like I'm still missing some env setup... any ideas? Thanks again!

So, I just installed Beyond Compare via the CrossTie file and ran it with

$ /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wine --bottle "Beyond Compare" --cx-app BCompare.exe

and it launched just fine. I didn't see any real difference between that launch and the launch from the Programs menu icon or by using Run Command, though I only poked at the program very briefly.

I don't think this is failing for you for want of the proper environment variables in Crossover 10. Your errors make it look more like the version of Crossover being invoked by the command is version 7 or earlier. Is this possible on your system? Do you have multiple copies of Crossover installed?

The first thing I'd suggest is to close Crossover, remove it entirely from your Applications folder and send it to the trash, and then re-install Crossover 10 (or whichever is the most recent version to which you have access that's at least version 8), and be sure that you're invoking that particular installation of Crossover from the command line when launching the program.

Any luck?

Thanks for that suggestion, Jack.

I nuked the old install and reinstalled it, and I got the same error.

I didn't have any other CrossOver version installed, but I do have other wine versions installed (via MacPorts).

I have CrossOver 10.0.3 installed (fresh download from Friday, June 27, 2011), on a Macbook Pro with OSX 10.6.7.

From the error message:

$ /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wine --bottle "Beyond Compare" --cx-app BCompare.exe
Can't load '/System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/Mac/Files/Files.bundle' for module Mac::Files: /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level/auto/Mac/Files/Files.bundle: no appropriate 64-bit architecture (see "man perl" for running in 32-bit mode) at /System/Library/Perl/5.10.0/darwin-thread-multi-2level/DynaLoader.pm line 207, <DATA> line 1.
at /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/lib/perl/CXBottle.pm line 66
Compilation failed in require at /Applications/CrossOver.app/Contents/SharedSupport/CrossOver/lib/perl/CXBottle.pm line 66, <DATA> line 1.

Could it be that some Perl install I have outside of CrossOver is confusing CrossOver?

Well, this is embarrassing. :/

On investigating why my results differ so markedly from yours, I discovered that an environment variable that's typically set by the "open shell" command was already set on a permanent basis in my Terminal environment. The variable in question:

VERSIONER_PERL_PREFER_32_BIT=yes

I can only assume that this was set in the process of unorthodox testing, which we do a fair amount of around here, but the end result is that launching Beyond Compare from command line works fine for me, and that all my advice preceding this post regarding the 'bare bones' approach in terminal is useless to most Snow Leopard users.

I haven't experienced any problems that I can identify as a result of this environment variable, but most Mac devs would surely tell you that having such a variable in place is a generally bad idea.

If you don't want to set this variable on a permanent/semi-permanent basis (and, again - you probably shouldn't), you could write a shell script that sets the minimum needed environment variables and then launches Beyond Compare with your args already set in the script. Such a script would look something like this:


#!/bin/sh

crossover="/Applications/CrossOver.app" # Where you keep CrossOver
bottle="Your Bottle Name Here"

open "$crossover"

export DISPLAY=:`defaults read com.codeweavers.CrossOver Display`
export DYLD_FALLBACK_LIBRARY_PATH="$crossover/Contents/SharedSupport/X11/lib:$HOME/lib:/lib:/usr/lib:/usr/X11/lib"
export FONT_ENCODINGS_DIRECTORY="$crossover/Contents/SharedSupport/X11/lib/X11/fonts/encodings/encodings.dir"
export FONTCONFIG_PATH="$crossover/Contents/SharedSupport/X11/etc/fonts"
export FONTCONFIG_ROOT="$crossover/Contents/SharedSupport/X11"
export VERSIONER_PERL_PREFER_32_BIT=yes
export CX_BOTTLE="$bottle"
export PATH="$crossover/Contents/SharedSupport/CrossOver/bin:$PATH"

# Uncomment this if you need to be in the bottle's C: drive directory
#cd "$HOME/Library/Application Support/CrossOver/Bottles/$bottle/drive_c"

wine YourProgramHere YourArgumentsHere

Perfect, that did the trick! I took your shell script and modified it a bit, here's the final working script:

#!/bin/sh

# Where you keep CrossOver
crossover="/Applications/CrossOver.app"
bottle="Beyond Compare"
exe_dir="Beyond Compare 3"
exe_name="BCompare.exe"

open "$crossover"

export DISPLAY=:`defaults read com.codeweavers.CrossOver Display`
export DYLD_FALLBACK_LIBRARY_PATH="$crossover/Contents/SharedSupport/X11/lib:$HOME/lib:/lib:/usr/lib:/usr/X11/lib"
export FONT_ENCODINGS_DIRECTORY="$crossover/Contents/SharedSupport/X11/lib/X11/fonts/encodings/encodings.dir"
export FONTCONFIG_PATH="$crossover/Contents/SharedSupport/X11/etc/fonts"
export FONTCONFIG_ROOT="$crossover/Contents/SharedSupport/X11"
export VERSIONER_PERL_PREFER_32_BIT=yes
export CX_BOTTLE="$bottle"
export PATH="$crossover/Contents/SharedSupport/CrossOver/bin:$PATH"

# Uncomment this if you need to be in the bottle's C: drive directory
#cd "$HOME/Library/Application Support/CrossOver/Bottles/$bottle/drive_c/Program Files/$exe_dir"
full_exe_path="$HOME/Library/Application Support/CrossOver/Bottles/$bottle/drive_c/Program Files/${exe_dir}/${exe_name}"

# This picks up the wine binary from newly modified PATH
wine ${full_exe_path} $@

Thanks again for all your help, Jack, I appreciate it!

1 to 10 of 10

Please Note: This Forum is for non-application specific questions relating to installation/configuration of CrossOver. All application-specific posts to this Forum will be moved to their appropriate Compatibility Center Forum.

CrossOver Forums: the place to discuss running Windows applications on Mac and Linux

CodeWeavers or its third-party tools process personal data (e.g. browsing data or IP addresses) and use cookies or other identifiers, which are necessary for its functioning and required to achieve the purposes illustrated in our Privacy Policy. You accept the use of cookies or other identifiers by clicking the Acknowledge button.
Please Wait...
eyJjb3VudHJ5IjoiVVMiLCJsYW5nIjoiZW4iLCJjYXJ0IjowLCJ0enMiOi02LCJjZG4iOiJodHRwczpcL1wvbWVkaWEuY29kZXdlYXZlcnMuY29tXC9wdWJcL2Nyb3Nzb3Zlclwvd2Vic2l0ZSIsImNkbnRzIjoxNzM0NzIyMzMzLCJjc3JmX3Rva2VuIjoieXZZcHNtOExobjJWSlNuVCIsImdkcHIiOjB9