Open Internet Link inside VM on Host Browser

This is for discussing general topics about how to use VirtualBox.
Post Reply
trendo
Posts: 2
Joined: 10. Dec 2014, 14:53

Open Internet Link inside VM on Host Browser

Post by trendo »

Hi,

my Host-System is Linux, my Guest is Windows-7.
Windows run's in Seamless-Mode, because I have to work with both systems simultaneously.
For some reasons I have to work with a Windows Email-Client, and It would be very helpful, if when i click on a link in an email (inside VM -> Windows), that then open the host Browser for it.

On a Mac that works with VMware-Fusion and with Parallels-Desktop easily. There you can set default applications for specific actions (For example: Links inside VM's open in Browser Firefox from Host, or clicked "mailto:" Links on Host open in Email Program from the VM-xy, Telnet..., FTP..., etc.)

In VirtualBox i can't find such Settings. Is something like this possible with Scripts?


Alex
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Open Internet Link inside VM on Host Browser

Post by scottgus1 »

There isn't a direct Virtualbox way to make that happen that I know of. If you have Guest Additions in the guest, you could use scripts running on the guest and the host to manipulate the "guestproperties" (See "Vboxmanage guestproperty" in the help files). Hack your Windows guest to redirect clicks on web links to a vbs script in the guest which sets a guestproperty with the contents of the link, then the host script monitoring the guestproperty would take the contents and feed them to the host browser. Jury-rigged, yes, but it might work.

Fusion and Parallels have just integrated their guests into the host in a different way than Virtualbox does. With Virtualbox, instead of "fusing" the guest and the host, so to speak, you get a "virtual box", another PC running in your PC. You'll just need to imagine things a bit differently. Think of them as two computers side by side, with an automatic KVM switch between them. How would you get the computers to interact in your desired way? Network, scripts, etc. Figure that out for two PCs side-by-side, and you'll have the way to make Virtualbox do what you want.
trendo
Posts: 2
Joined: 10. Dec 2014, 14:53

Re: Open Internet Link inside VM on Host Browser

Post by trendo »

Ok, thanks for the Info.
Do you have such Scripts or other Sample-Scripts?
I searched but have not found anything.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Open Internet Link inside VM on Host Browser

Post by scottgus1 »

No, it's likely such scripts don't exist in the form you need them. You'll have to learn vbscript and Virtualbox's Vboxmanage command (btw, Vboxmanage in the guest is called "vboxcontrol.exe". There's a Software Development Kit (SDK) for Virtualbox you should look at, and I'll point you to a post I had once on using Guestproperties as a heartbeat indicator between guest and host here: viewtopic.php?f=1&t=48146

Here's a vbscript I wrote once to check the heartbeat, which you might be able to use to monitor for the guestproperty on the host (this is just to demonstrate how vbscript and Virtualbox can work together - it does not do what you want in this present script):

Code: Select all

set vb = CreateObject("VirtualBox.VirtualBox")
Set shell = WScript.CreateObject ("WSCript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")

budrive="E:\VMbackups"
timeout = 120 ' seconds to get good heartbeats from all VMs
pausedelay = 5 ' seconds to pause between tests
runevery = 5 'minutes between start of tests

Set Server2003 = vb.findMachine("Server2003")
Set Antispam = vb.findMachine("Antispam")
Set CVserver = vb.findMachine("CVserver")
Set EmailTester = vb.findMachine("EmailTester")

DO

teststarttime = timer
'less than 'runevery' minutes to midnight?
if (teststarttime + runevery * 60) > 86400 then teststarttime = teststarttime - 86400 

if not fso.fileexists(budrive&"\bucmd.flg") then 'don't test if backup is running or VMs were manually shut down 

'these set/getGuestProperty commands fail if the machine is not running, 
'need to test for running vm to keep this script from crashing

  Server2003.setGuestPropertyValue "/vmcontrol/heartbeat","0"
  Antispam.setGuestPropertyValue "/vmcontrol/heartbeat","0"
  CVserver.setGuestPropertyValue "/vmcontrol/heartbeat","0"
  EmailTester.setGuestPropertyValue "/vmcontrol/heartbeat","0"

  counter = 0
'  do
    allHB = false
    HBServer2003 = Server2003.getGuestPropertyValue("/vmcontrol/heartbeat")
    HBAntispam = Antispam.getGuestPropertyValue("/vmcontrol/heartbeat")
    HBCVserver = CVserver.getGuestPropertyValue("/vmcontrol/heartbeat")
    HBEmailTester = EmailTester.getGuestPropertyValue("/vmcontrol/heartbeat")
    if HBServer2003 = "1" and HBAntispam = "1" and HBCVserver = "1" and HBEmailTester = "1" then
      allHB = true
      exit do
    end if
    wscript.sleep pausedelay*1000
    counter = counter + pausedelay
'  loop until counter > timeout

  if allHB then

    'if no external drive was present at vmstart...
   if fso.fileexists("E:\vmbackups\noextdr.flg") then
      'test for backup drive
      lgldrv="ZYXWVUTSRQPONMLKJIHGFE#"
      for x = 1 to len(lgldrv)
        letter = mid(lgldrv,x,1)
        if letter="#" then exit for
        if fso.fileexists(letter&":\VMbackup\budrive.mark") then exit for
      next
      if letter<>"#" then 'valid backup drive found
        shell.run "c:\vmcontrol\CopyVMs2USBnet.cmd"
      end if
    end if
    response=shell.Popup("VMs running well",3,"Heartbeat test")  

  else

    shell.run "c:\vmcontrol\VMstuckHandle.cmd"' " & HBServer2003 & " " & HBAntispam & " " & HBCVserver & " " & HBEmailTester

  end if

end if 'bucmd.flg exists?

do ' timer loop
wscript.sleep 10000
loop until timer > (teststarttime + runevery * 60)

Loop
markd89
Posts: 34
Joined: 4. Sep 2016, 22:54

Re: Open Internet Link inside VM on Host Browser

Post by markd89 »

Bumping this thread, to see if such a capability has been added since 2015 or more ideas to achieve the same thing?

(i.e. Linux host, Windows guest. Click an .html link on the guest and have it get opened in the host browser).

Thanks!
Mark
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Open Internet Link inside VM on Host Browser

Post by socratis »

markd89 wrote:to see if such a capability has been added since 2015
No. And I don't think it will, the security hazard alone would be a no-go...
It's not that difficult to copy/paste, is it?
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
markd89
Posts: 34
Joined: 4. Sep 2016, 22:54

Re: Open Internet Link inside VM on Host Browser

Post by markd89 »

LOL, no it's not that hard.

Thanks,

Mark
Last edited by socratis on 22. Feb 2018, 01:48, edited 1 time in total.
Reason: Removed unnecessary verbatim quote of the whole previous message.
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: Open Internet Link inside VM on Host Browser

Post by socratis »

Code contributions are always welcome, especially if they're easy...
Doesn't necessarily mean that they will be implemented, though.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
markd89
Posts: 34
Joined: 4. Sep 2016, 22:54

Re: Open Internet Link inside VM on Host Browser

Post by markd89 »

Ah, no, I wasn't bragging. My C skills are not great these days.

I was meaning that you're right, it's not that difficult to cut and paste.

That said, I do have an idea on some hacks and may play with it more.

If I get something that works nicely, I will share.

Thanks again,

Mark
markd89
Posts: 34
Joined: 4. Sep 2016, 22:54

Re: Open Internet Link inside VM on Host Browser

Post by markd89 »

I have a nice working solution to this.

The basic idea is:

1. Run a web server created in a Python script in the Linux host waiting on a non-standard port.

2. In the Windows guest, redirect url handling to something that will pass the url to the web server running on the host.

3. The Python script web server takes the url and passes it to the browser on the host.

Most of the recipe can be found here:
https://superuser.com/questions/140234/ ... -open-in-t

See the answer "I had the same idea as Ignacio Vazquez-Abrams and I implemented it."

See also my improvements "I don't have 50 points, so I can't comment under Oleh Pyrpin's post."

I did this for fun/challenge and am happy with the results. I don't think it creates a security issue, at least for me. My windows machine is very locked down. The script listening on the host side is listening on a non-routeable IP.

I hope this helps someone else.

Mark

P.S. I thought of a cool enhancement, which I'm probably not going to build... Maybe I want to launch a PDF file from the Windows guest to it opens on the Linux host. I have shared folders between guest and host. A script could be created and made the default handler of PDF files on the guest. This could post the path/filename to the web server. We'd need to detangle the path so that it makes sense to the Linux side. i.e. H:\docs in Windows is /home/user/bob/shared/docs on the Linux side.
Post Reply