Tutorial: better integration of VirtualBox (Windows) into MX Linux (guide in steps)

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
User avatar
Duliwi
Posts: 1176
Joined: Sun Jul 07, 2019 9:34 am

Tutorial: better integration of VirtualBox (Windows) into MX Linux (guide in steps)

#1 Post by Duliwi »

What will be the benefit, when anybody has implemented these steps?


A) Opening for example a "Microsoft Word"-file (or any other Windows file-typ) in thunar with "double click":


-Without this tips: We must start VirtualBox. After we have to choose and start our VM. Then we have to wait until the VM is booted. This takes a while. Then we have to start "Windows Explorer" and search the Word-file, we want to open. Then we can double click it.

-When these tips are implemented: You just open thunar (in Linux). Search your file and double click it. Done.
Then automatically the right VM starts and the Word-file will be opened with "Microsoft Word". (Windows must not boot, because it was in save state. So this way Windows will be ready faster.) This not only works with word-files, but this works with any file for which a program is installed in the Windows VM.

-Also when you are surfing in the internet with Firefox and have a link to a word document (or any other file-typ that needs a program, that you have in your VM), then just click "open" in Firefox and it will automatically start in your VM with the matching windows program.
-Same, when you want to open for example a *.docx file attachment in Thunderbird.
-Simlinks can also be opened the same way.



B) Starting for example "Microsoft Word" (or any other Windows-Program):

-Without this tips: We must start VirtualBox. After we thave to choose and start our VM. Then we have to wait until the VM is booted. This takes a while. After, we have to look for the "Microsoft Word" starter in the VM and start it.

-Starting "Microsoft Word" when these tips are implemented: You will have a "Microsoft Word" starter in Linux. The starter can be on the desktop, in the menu or in the panel. The only thing you have to do, is to click on this starter. Done.
Then automatically the right VM starts and "Microsoft Word" starts. (Windows must not boot, because it was in save state. So this way Windows will be ready faster. Edit: But it also works, if you shut your PC down.)

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

"How to do"-guide in steps (for variant A) from above):

0. Pre-requisite: You have already a Windows VM with your prefered Windows programs. For this description I have used "Windows 7 32bit" and as windows programs "Office 2010". (I assume that it also works with other versions of windows. And with any windows-programs.)
Please note: This is an implementation for MX Linux 19.3 Xfce.

1. Steps you have to do with "windows user password":
Give your windows account a password (this is mandatory):
a. Start your windows VM
b. press WindowKey+R
c. type in: compmgmt.msc
d. open the Users folder in Local Users and Groups
e. Right-click your user account and choose Set Password.
f. Proceed to continue
g. Enter a new password, reenter it and click OK.

This is also needed:
h. press WindowKey+R
i. type in: gpedit.msc
j. Navigate to -> Computer Configuration\Windows Settings\Security Settings\Local Policies\Security Options
k. Change -> "Accounts: Limit local account use of blank passwords to console logon only" to "disabled".

This is needed so that you need not to type in manually your password, when you have shut down your VM instead of using the "save state" mode:
l. start your Windows-VM an log you in.
m. Press Win + R, enter netplwiz and press Enter. This opens the dialogue box for user accounts.
n. In the ‘User accounts’ dialogue box, select the user account that is to be logged in automatically.
o. Deactivate the option Users must enter user name and password and click on Apply.
p. Another dialogue box appears in which you must enter the user name and password of the account that is to be logged in automatically. Enter the password twice and confirm with OK.
q. Close all open dialogues with OK.
r. Shut down your VM.

2. VirtualBox: Set up "shared folders":
a. open VirtualBox Manager
b. right click on your Windows VM
c. choose "change" -> tab "shared folders"
d. add a new folder with path "/tmp" (this is necessary when you later click in Firefox on a "MS Word" link. So that this *.docx can be opened automatically in your Win-VM; Or when you have an attachment in Thunderbird, you want to open.)
e. check "Integrate automatically" and "only readable"
f. Embedding point "H:"
g. add a new folder with path "/home/MyUsername" (replace "MyUsername" with your Linux-account name). This is the place where all your files are, that you wont to be able to open directly with double clicking in thunar (See "A)" above). When your files, that you want to open in with windows programs, are all in a particular folder, then you can choose here this particular folder.)
h. check "Integrate automatically" and leave unchecked "only readable"
j. Embedding point "G:"


3. Start your VM
4. choose -> menu -> view -> "Full screen mode"
5. choose -> menu -> view -> Seamless mode
6. Change to "Oracle VM VirtualBox Manager"
7. Menu -> machine -> close -> "save state" (You must always close this VM this way. This is something like "hibernate" in Windows. It makes, that your VM will start faster.
8. Copy the attached file "Windows7VM.sh" into "/home/YourUserName/.bin/" (Replace YourUserName with your user name. If you do not have this folder, create it.)

In the file "Windows7VM.sh" you have to replace some lines:
Line 3: replace "Win7NeuFurOfficeVersuch" through the name of your VM. You find the name of your VM in the "Oracle VM VirtualBox Manager". It's the bold part of the name at the left side of the window.
Line 10: replace "/home/user/" through the path that you have set up in 2.g. (see above)
Line 31: replace "WindowsAccountName" through the "account name" of your windows in your VM. (Pardon, what name exactly? When you normally start windows, you have to log-in and your account name is shown. This is the name, you have to take here.)
Line 32: replace "MyPassword" through your windows password of your "windwos account" you have set up in 1.g. (see above)
Line 42: replace "Win7NeuFurOfficeVersuch" through the name of your VM. You find the name in "Oracle VM VirtualBox Manager". It's the the bold part of the name at the left side of the window.
Line 50: replace "Win7NeuFurOfficeVersuch" through the name of your VM. You find the name in "Oracle VM VirtualBox Manager". It's the the bold part of the name at the left side of the window.
Line 55: replace "Win7NeuFurOfficeVersuch" through the name of your VM. You find the name in "Oracle VM VirtualBox Manager". It's the the bold part of the name at the left side of the window. And replace "MyUsername" through your "Windows user name". And replace "MyPassword" through your "Windows password".

Edit: To bring it into work with MX-23 Xfce and VirtualBox 7.0.16 you have to change the following line:
--exe "%SystemRoot%\system32\cmd.exe"
through ...
--exe "C:\Windows\System32\cmd.exe"

9. Make the file "Windows7VM.sh" executable, if it is not already executable. (Right click on the file-> properties-> Tab "rights")
10. Copy the attached file "Windows7-VM.desktop" to the folder "/home/user/.local/share/applications/" (replace user to your Linux user-name)

In this "Windows7-VM.desktop" you have to replace
Line 3: "User" through your Linux user name.

Variant A) (see above) should now work.


How to use it?
-open thunar
-go to the file you want to open in your VM (This file must be in a folder, that is entered in VirtualBox as "shared folder". See above "point 2")
-make a right click on it -> "open with" -> "Open with another application"
-check "Use by default for files of this type"
-choose "windwos7 VM" from the list

---------------------------------------------------------------------------------------------------------------------------------------------------------------

Additional steps for B)

(Please note: This "steps for B)" only work, when you also have implemented all steps above.)

Just download the attached "Microsoft starters" for Linux.
Copy them to the folder "/home/user/.local/share/applications/Windows_VM_Programs/" (Replace "user" through your "Linux user name")
Open each of this starters in Featherpad and replace in the line

Code: Select all

Exec=/home/user/.bin/Windows7VM.sh "C:\\Program Files\\Microsoft Office\\Office14\\Winword.exe"
"user" through your "Linux username".

Copy the attached file "VirtualBox-VM-Programs.directory" into the folder

Code: Select all

/home/user/.local/share/desktop-directories/
(replace user)

Copy the attached file "VirtualBox-VM-Programs.menu" into the folder

Code: Select all

/home/user/.config/menus/applications-merged/
(replace user)


-> Now you will have this starters in your Whisker menu (Category VirtualBox-VM-Programs)
(Thank you for your kind help @dolphin_oracle)

Just download in addition the attached icons to get Microsoft Symbols for your starters.
Copy them into the matching folders:
/home/user/.local/share/icons/hicolor/16x16/apps/
/home/user/.local/share/icons/hicolor/32x32/apps/
/home/user/.local/share/icons/hicolor/48x48/apps/
/home/user/.local/share/icons/hicolor/96x96/apps/
/home/user/.local/share/icons/hicolor/128x128/apps/

---------------------------------------------------------------
Main source for this guide: https://unix.stackexchange.com/question ... rough-virt



FAQ:


Question: What do I have to do, when I want to open for example an *.pdf file with the newest "Foxit Reader" with right click in thunar? (https://www.foxitsoftware.com/downloads/)
Answer: You have already implemented all you need for this. The only thing you need, is to link the file typ *.pdf with "windwos7 VM". See above section "How to use it?" .


Question: What do I have to do, when I want to start "Foxit Reader" with a starter. I have no starter for this?
Answer: Just open one of the attached "Microsoft starters" in Featherpad and you see how such a starter works. Then you can replace the lines

Code: Select all

Name=Word VM
Exec=/home/user/.bin/Windows7VM.sh "C:\\Program Files\\Microsoft Office\\Office14\\Winword.exe"
Icon=0575_wordicon.0

Question: How can I open an attachment in Thunderbird with a programme that is in the Windows VM?
Answer: You have already created the preconditions in step 2. d) above and with the existing section in "Windows7VM.sh" that looks like this:

Code: Select all

# /temp/ is mounted as H:
original=$fixedFilePath
findWhat="/tmp/"
replaceWith="H:\\"
fixedFilePath="${original/$findWhat/$replaceWith}"
Assumed you have an *.docx attachment in an E-Mail in thunderbird, you can make this additional steps:
1. Open Thunderbird
2. open menu -> edit -> settings -> general -> File & attachments
3. In the list go to the entry (Microsoft Word Document: application/vnd.openxmlformats-officedokument.wordprocessingml.document) and on the right side select "use other"
4. Go to "/home/YourUserName/.bin/" and open "Windows7VM.sh"
5. It's now selected in the column "Action"
6. When you click on it, you can see, that it is now in the list.
7. Select now in this list "always ask"
8. Close the settings tab
5. Go to your mail with the *.docx attachment
6. click or double click it
7. Check the option "open with"
8. select "other"
9. "Windows7VM.sh should be now in the list right of "open with"
10. select it, wait some seconds until the OK button is activ and then open it. Done.

-> Please not: It can be, that you do not have the fitting entry in "menu -> edit -> settings -> general -> File & attachments".
In this case the fist thing (step 0) you have to do, is to open (in this case) the *.docx document with any programme. For example LibreOffice or whatever programme is offered for you. This way thunderbird generates automatically a fitting entry in "menu -> edit -> settings -> general -> File & attachments". This means, after this step "0" you will have an additional entry in "menu -> edit -> settings -> general -> File & attachments" and you can continue with step 1 above.


Question: Should I "shut down" my Windos VM, when I am done?
Answer: No. First close all open windows programs in you VM. Then put the VM into the "save state". For example this way: Go to "Oracle VM VirtualBox Manager"; Menu -> machine -> close -> "save state" . You also can make a "key combination" for this:
-> Xfce settings -> keyboard -> tab "short keys for programs" -> add -> Command:

Code: Select all

VBoxManage controlvm "Win7NeuFurOfficeVersuch" savestate
(replace "Win7NeuFurOfficeVersuch" through the name of your VM.)
Edit: But yes, if you want, you can alternatively shut down the VM. It can be, that the start will need a bit longer with this method.


Question: When I set my VM into "save state" is my VM then still running in the background?
Answer: No. It's not "sleeping" or "standby" or "pause". It's more something like "hibernate" in Windows. I guess, it also saves the content of your RAM on the HD, so that the VM is able to start faster again.





.
You do not have the required permissions to view the files attached to this post.
Last edited by Duliwi on Tue Jun 04, 2024 8:29 am, edited 51 times in total.

User avatar
Duliwi
Posts: 1176
Joined: Sun Jul 07, 2019 9:34 am

Re: How to do guide: better integration of VirtualBox into MX Linux

#2 Post by Duliwi »

Here are the icons
You do not have the required permissions to view the files attached to this post.

jonnken
Posts: 142
Joined: Thu Mar 14, 2019 12:22 pm

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

#3 Post by jonnken »

Perhaps the task of learning LibraOffice...is less than figuring out and operating a virtual box? With LibraOffice you're able to work and save seamlessly with all type Word type files. No more worries about compatibility with this or that. Most methods in LibraOffice are quite similar to the MS Word environment. The learning curve is not that steep from Word to LibraOffice.
Regards, jonnken...since Feb 2019
Dell Optiplex 7020...Intel i5-4690...500G HD...MX-23_x64

SwampRabbit
Posts: 3602
Joined: Tue Jun 14, 2016 2:02 pm

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

#4 Post by SwampRabbit »

Nice tutorial, its on the list of things to check out, thanks for sharing.

jonnken wrote: Thu Jan 21, 2021 9:23 am Perhaps the task of learning LibraOffice...is less than figuring out and operating a virtual box? With LibraOffice you're able to work and save seamlessly with all type Word type files. No more worries about compatibility with this or that. Most methods in LibraOffice are quite similar to the MS Word environment. The learning curve is not that steep from Word to LibraOffice.
I think the use of Word was just an example, they did state "or any other Windows-Program".
While I like LibreOffice, creating or editing MS Office documents without then checking if they look and act fine in actual MS Office, usually leads to trouble. When it comes to MS Office documents I need for work, I stopped relying on LibreOffice really. It is not fun to be in a meeting and someone opens up your PowerPoint slides or a Word document and the format is all messed up.

I find this very interesting and see how it can come in handy for many things. Using WINE is good, but this method Duliwi is sharing also lets you open and execute files inside a VM and not directly on your system. Would be interesting to see what people adapt and use this for.
NEW USERS START HERE FAQS, MX Manual, and How to Break Your System - Don't use Ubuntu PPAs! Always post your Quick System Info (QSI) when asking for help.

jonnken
Posts: 142
Joined: Thu Mar 14, 2019 12:22 pm

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

#5 Post by jonnken »

My use of LibraOffice is mostly personal and I know the cross formatting can be an issue. I do know that the LibraOffice spreadsheet crashes more than Excel did for me. But overall LibraOffice seems better for me, than figuring out and operating with the additional virtual machine elements. Oh, the great versatility of Linux.
Regards, jonnken...since Feb 2019
Dell Optiplex 7020...Intel i5-4690...500G HD...MX-23_x64

User avatar
Duliwi
Posts: 1176
Joined: Sun Jul 07, 2019 9:34 am

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

#6 Post by Duliwi »

@jonnken
As @SwampRabbit has said.
-> This tutorial is for any windows-program for which anybody has not found a replacement or is not willing to use a replacement.

User avatar
andyprough
MX Packager
Posts: 918
Joined: Tue Jul 23, 2019 10:16 pm

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

#7 Post by andyprough »

Duliwi wrote: Thu Jan 21, 2021 8:37 am What will be the benefit, when anybody has implemented these steps?


A) Opening a for example "Microsoft Word"-file (or any other file-typ) in thunar with "double click":


-Without this tips: We must start VirtualBox. After we have to choose and start our VM. Then we have to wait until the VM is booted. This takes a while. Then we have to start "Windows Explorer" and search the Word-file, we want to open. Then we can double click it.
Very interesting, I did not know this was possible. Have you run into any trouble with it? Any breakage of Windows or corruption or loss of files?

I'd like to try it, but don't want to risk losing any files or breaking Windows in order to gain the convenience.
Primary Computer - Commodore 64: Processor - MOS 6510/8500, 1.023MHz; Memory - 64kb RAM, 20kB ROM - 8k BASIC V2, 8k Kernel, 4k Character ROM; Display output - 320x200, 16 colours; OS - BASIC V2.0; Weight: 1.8kg

User avatar
Duliwi
Posts: 1176
Joined: Sun Jul 07, 2019 9:34 am

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

#8 Post by Duliwi »

@andyprough
If you want to be on the safe side, you can first take a snapshot of the current state of your VM in VirtualBox:
Oracle VMVirtualBox Manager -> snapshot -> take...

jonnken
Posts: 142
Joined: Thu Mar 14, 2019 12:22 pm

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

#9 Post by jonnken »

Duliwi wrote: Thu Jan 21, 2021 11:44 am @jonnken
As @SwampRabbit has said.
-> This tutorial is for any windows-program for which anybody has not found a replacement or is not willing to use a replacement.
Yes, the more I look over what you're working on...the more I see it's broader applications and potential. The MS Windows compatibility with Linux is the major roadblock that keeps a good many users away. But to have a more seamless integration thru virtual box...would indeed have real value to lots of people.
Regards, jonnken...since Feb 2019
Dell Optiplex 7020...Intel i5-4690...500G HD...MX-23_x64

User avatar
andyprough
MX Packager
Posts: 918
Joined: Tue Jul 23, 2019 10:16 pm

Re: Tutorial: better integration of VirtualBox into MX Linux (guide in steps)

#10 Post by andyprough »

Duliwi wrote: Thu Jan 21, 2021 11:51 am @andyprough
If you want to be on the safe side, you can first take a snapshot of the current state of your VM in VirtualBox:
Oracle VMVirtualBox Manager -> snapshot -> take...
I know how to be on the safe side with snapshots and cloning, that was not my question. Really I want to know - have you experienced any breakage or corruption or any negative consequences?
Primary Computer - Commodore 64: Processor - MOS 6510/8500, 1.023MHz; Memory - 64kb RAM, 20kB ROM - 8k BASIC V2, 8k Kernel, 4k Character ROM; Display output - 320x200, 16 colours; OS - BASIC V2.0; Weight: 1.8kg

Post Reply

Return to “Tips & Tricks by users”