Friday, May 27, 2022

[SOLVED] Run windows program with wine and root privileges

Issue

I know that is not recommended but i have a windows program that need root privileges to be run. (uses wpacp to read ethernet interfaces).

If I run wine myprogram.exe my program tell me that I don't have permission to read interfaces)

But If i run wine as sudo, wine tell me that .wine is not owned by you.

Any solution?


Solution

To be able to run wine with sudo you got to have a wineprefix owned by the root user.

Running:

sudo chown root ~/.wine

would solve this particular problem but i'd recommend against doing that, since then you won't be able to use wine as a normal user.

A better alternative could be to make a second wineprefix owned by the root user with:

sudo WINEPREFIX=~/.wine_root winecfg

(use default location, or provide an alternative)

Then you can just run the program with

sudo WINEPREFIX=~/.wine_root wine /path/to/your/program.exe

Although this can be done, running wine with sudo is pretty dangerous so you may want to avoid it at all if possible.



Answered By - Yiannis Kontochristopoulos
Answer Checked By - Katrina (WPSolving Volunteer)