Ubuntu – Wine 1.5 %ProgramFiles% error

12.10winewinetricks

I'm trying to install d3dx9 with winetricks on wine 1.5 from ppa and I keep getting an error. I tried:

WINEARCH=win32 WINEPREFIX=~/.win32 winecfg 
sudo WINEARCH=win32 WINEPREFIX=~/.win32 winetricks

And still get this error:

wine cmd.exe /c echo '%ProgramFiles%' returned empty string

If I type wine cmd.exe /c echo '%ProgramFiles%' into the terminal I get C:\Program Files so the path seems correct but not when I run winetricks.

I also tried this regedit fix with no luck.

Any ideas?

Best Answer

I see you use sudo in one of your winetricks commands: that could be the main problem, as sudo shouldn't be used with wine or winetricks (only when running sudo apt-get install wine); see my comment at the end of my post.*

When I successfully installed d3dx9 to a separate wine prefix, which I see you are also using, I used the below command in the terminal.

WINEPREFIX=$HOME/.myprefixname winetricks d3dx9

This is part of the voluminous output I got from the command using the WINEPREFIX:

Executing cabextract -q -d /home/mike/.myprefixname/dosdevices/c:/windows/system32 -L -F d3dx9*.dll /home/mike/.myprefixname/dosdevices/c:/windows/temp/_d3dx9/apr2006_d3dx9_30_x86.cab

You must change .myprefixname to the name of your own prefix; for more explanation of wine prefixes and their use, please see this question.

You only need to specify WINEARCH=win32 or the 64bit equivalent when you create the prefix, as it can't be altered afterwards, as noted at WineHQ. Wine will also refuse to load if you specify a different WINEARCH to the one you created it with.

Just entering in terminal winetricks d3dx9 would instead install directX to your default ~/.wine folder.

*It is most important to note that when installing things with winetricks or using wine, you don't need to use sudo, as you are not installing the files to the system, but to your Wine folder or separate wine prefix in your home folder. Using sudo might cause the problem you are experiencing with paths, as is noted on the actual link given. In the WineFAQ it notes that

Running with sudo...has the added bonus of breaking the permissions on your ~/.wine folder in the process. If you have run Wine with sudo you need to fix the permission errors... and then run winecfg to set Wine up again.

So, I should also check your permissions and refer to the WineFAQ article, as you will need to reset your permissions even if you reinstall wine. If you have used sudo with wine and now root owns some of the files, you will need to change the permissions by running the following commands from the WineFAQ:

cd $HOME  
sudo chown -R $USER:$USER .wine 

Replace .wine with your prefix if you use a WINEPREFIX or use the command for both your .wine folder and your prefix if you have both.