Page 1 of 1

Remotely Start VIrtual Machine

Posted: 22. Feb 2012, 18:50
by W3bby
I wish to be able to start a Virtual machine that is hosted on my Windows 7 64Bit computer in my office from a Machine (Windows XP) in my workshop.
I can Remote desktop the machine if it is already running - and does everything I want.
However I have numerous virtual machines and they can't (don't need) all be running at the same time. I would just like to be able to start the one I want and then remote desktop in to it to use it when I want.

I can already start Vbox in the command line using vboxmanage and vboxheaderless but this doens't solve my problem.
I have tried using PSExec and loading the Vbox but this fails.

Anyone know how to do this?
Thanks in advance!

Re: Remotely Start VIrtual Machine

Posted: 22. Feb 2012, 18:56
by Perryg
Why not remote into the host and start whatever and then access it there or in another remote session?

Re: Remotely Start VIrtual Machine

Posted: 22. Feb 2012, 19:14
by W3bby
Obviously this is possible, but 1) is a pain 2) If someone is using the Win 7 PC for other things it inturrupts their work 3) It loggs them out and how would they know when they could log back in again.

Re: Remotely Start VIrtual Machine

Posted: 22. Feb 2012, 21:04
by scottgus1
I don't believe Virtualbox has a way to do what you want built-in. Psexec works pretty good if the PCs are on a domain. The real killer with that "app" is the username and password. I found Psexec failed many times due to permissions.

I once did a remote-start VBS script to do things on my kids' PC. Here is the code. Copy & paste into a Notepad file, save as RemoteRun.vbs (and make sure you have your extensions visible, or it'll save as RemoteRun.vbs.txt and won't work):

Code: Select all

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set shell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
scriptpath = fso.getparentfoldername(wscript.scriptfullname)
title="Remote Run"

rrcode="xxxyyyzzz" 'authorization string, put on first line of remote command file
rrstop="stop"  'if this is the second line, this script quits
rrpathname="c:\remoterun\0123456789.rrc 'path to a shared folder on the host PC, and the filename of the remote command file
rrmsgbox=1 'if 1, a popup message will appear on the host PC

checkpath=fso.getparentfoldername(rrpathname)
if not fso.folderexists(checkpath) then
  msgbox "The programmed command path '"&checkpath&"' does not exist. Please check it out.",,title
  wscript.quit
end if

do 'main loop
  if fso.fileexists(rrpathname) then
    set rrcommand=fso.opentextfile(rrpathname,forreading,true)
    if not rrcommand.atendofstream then passcode=rrcommand.readline
    if passcode=rrcode then 'passcode good
      if not rrcommand.atendofstream then command=rrcommand.readline
      if command=rrstop then exit do
      response=1
      if rrmsgbox=1 then response=shell.popup("Executing: " & command,5,title,64+1)
      if response=1 or response=-1 then 'OK or nothing pushed, run command
        on error resume next
        shell.run command,1,false
        on error goto 0
      end if 'response
    end if 'passcode good
    rrcommand.close
    fso.deletefile rrpathname,true
  end if 'command file exists
  wscript.sleep 5000
loop 'main loop

rrcommand.close
if fso.fileexists(rrpathname) then fso.deletefile rrpathname,true
shell.popup "Stopped",5,title,64
Make a folder called remoterun on your Windows 7 Host PC, and share it so you can save files to it from your XP machine. Run RemoteRun.vbs on the Win7 PC. It will sit and wait for a file 0123456789.rrc to show up in the c:\remoterun folder.

Now, on your XP PC desktop, make a text file, call it 0123456789.rrc, and type two lines of text into it. The first should be xxxyyyzzz and the next should be your VboxManage command you'd use to launch the VM on your Win7 PC. Saave it, and copy it into the shared Remoterun folder on the Win7 PC. If everything is right, the VM should launch within seconds.

Re: Remotely Start VIrtual Machine

Posted: 23. Feb 2012, 18:02
by W3bby
Wow thanks ScottGus, that is a pretty through explination!
It is a bit tricky for me to be asking my staff to make files and write Vbox Manage commands though.

The PSExec route (presuming I can just write a .bat file to perform the required task) seems a more straight forward option (Having said that I havent had any of the password Issues you mention the times I have tried I have been granted access - maybe I was lucky)

What / how did you do it with PSTools if you can remember?

Thanks again!

Re: Remotely Start VIrtual Machine

Posted: 23. Feb 2012, 20:30
by scottgus1
I never did get PSexec to run reliably, due to permissions. With Windows 7 and UAC I imagine it would be harder. But either PSexec or RemoteRun will require a batch file on the remote PC to either execute the PSexec command or copy the .rrc file. Once you get one or the other working, a shortcut on the remote PC's desktop should take all the guesswork out for your users.