by whiter » 18. Oct 2007, 22:07
Not wishing to be defeated by this, I have kept at it and finally found a solution for firing up vbox command line tools that appears to work entirely from within cygwin ssh without any need for freessh. The root of the problem would appear to be a combination of unexpected environment variables and lack of interaction with the desktop.
1) You need to enable the sshd service to be interactive with the desktop - I suspect this may be because the vbox server has hidden windows which the system nevertheless considers interactive.
Within computer management - services, go to cygwin sshd, stop it, tick "allow service to interact with the desktop" from the logon tab, and restart the service.
2) You need to establish a batch file which replaces all of the cygwin environment variables with ones expected in the native windows environment before calling the vbox command line tools from within the same batch file. It is likely that the one or two 'problem' environmental variables could be traced and only these changed, but I didn't bother to do a trial and error hunt - it is much easier to replace the lot!
Best way - from the cygwin ssh when logged into the sshd server machine, do a "set > [somefile.txt]" which will dump all the cygwin variables into a file. Do the same into another file from a native cmd prompt on the sshd server machine. Use something like MS Word with good find/replace facilities to edit the two files so each line in the
first cygwin file now reads "set [name of variable]=" thus 'unsetting all the cygwin variables. Edit the file you have output from the cmd prompt by just adding "set " at the front of each variable. Combine all the lines into a batch file so that all the 'unset' commands come first followed by the ones which set the windows environment.
Now add to the bottom of the .bat file any required commands, in normal windows command line format, to change to the vbox directory and run the command line tools. Remember these must always be run from WITHIN the batch file because once you exit, the variables are lost, and cygwin reverts back to its own environment which being unix based is not entirely compatible with windows apps.
You can run any batch file from within a cygwin ssh session by 'cd' to its directory, then run:
"./[name of file including .bat]"
So, in summary, your finished batch file should look something like this:-
set variable1=
set variable2=
.
.
...(commands to unset cyg variables)
.
.
set variablea=valuea
set variableb=valueb
.
.
...(commands to set win native variables)
.
.
cd "c:\program files\innotek virtualbox"
vboxvrdp -startvm "Windows XP"