Page 1 of 1

Fail to open/run VboxManage.exe on win8.0

Posted: 23. Sep 2013, 07:08
by TB
Upgrading from win7 to 8, i also brought along a script that worked just fin with win7. On win8 i`m unable to open or start vboxmanage.exe(it opens and seems to run but closes without VB guest starting).
I use this code to run Vboxmanage.exe

Code: Select all

@echo off

REM Set the path of the VBoxManage executable.
set vboxmanage="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"

REM Set the name or uuid of the virtualbox to start.
set vmname="Type the name of the VM here..."

REM Set the target date information.
set target_day=10
set target_month=11
set target_year=2010

REM The tokens delims for the output of date, check with date /t what your format is.
REM [Dutch]      When the output is in the format 'do 24-05-2010' the value must be "tokens=2 delims=\ "
REM [US/English] When the output is in the format '24-05-2010' the value must be "tokens=1 delims=\ "
set tokens_delims_output="tokens=2 delims=\ "

REM The tokens and delims for the date, this specifies the delimiter of the date.
REM [Dutch] First, second and third value when delimited by a '-', set the value to "tokens=1,2,3 delims=-"
REM [US] First, second and third value when delimited by a '/', set the value to "tokens=1,2,3 delims=/"
REM [German] First, second and third value when delimited by a '.', set the value to "tokens=1,2,3 delims=\."
set tokens_delims_date="tokens=1,2,3 delims=-"



:getcurrentdate
REM Get the current year.
REM Set the token to 1 when the date /t does only output the date (without day name), otherwise this must be 2.
@For /F %tokens_delims_output% %%A in ('Date /t') do @(
  Set current_date=%%A
)

REM Change the character after delims with the delimiter for your date.
REM Also reverse the day and month value assignment, if the month comes before the day in your date locale.
@For /F %tokens_delims_date% %%A in ('echo %current_date%') do @(
  Set current_day=%%A
  Set current_month=%%B
  Set current_year=%%C
)

REM Check whether the day of the month start with a 0, than remove that char.
set current_day_first_char=%current_day:~0,1%
set current_day_second_char=%current_day:~1,1%
if "%current_day_first_char%" == "0" set current_day=%current_day_second_char%

REM Check whether the month start with a 0, than remove that char.
set current_month_first_char=%current_month:~0,1%
set current_month_second_char=%current_month:~1,1%
if "%current_month_first_char%" == "0" set current_month=%current_month_second_char%

echo The current year is '%current_year%', month is '%current_month%' and day is '%current_day%'.



:calculatedatediff
REM We first multiply the number of months with 30, than we check
set /a days_per_month=365/12

set /a target_finishedmonths=%target_month%-1
set /a current_finishedmonths=%current_month%-1

set /a target_dayofyear_finishedmonths=%target_finishedmonths%*%days_per_month%
set /a current_dayofyear_finishedmonths=%current_finishedmonths%*%days_per_month%

set /a target_dayofyear=%target_dayofyear_finishedmonths%+%target_day%
REM echo target_dayofyear=%target_dayofyear%
set /a current_dayofyear=%current_dayofyear_finishedmonths%+%current_day%
REM echo current_dayofyear=%current_dayofyear%
set /a year_diff=%current_year%-%target_year%

set /a day_diff=%current_dayofyear%-%target_dayofyear%
REM echo day_diff=%day_diff%

if %day_diff% GEQ 0 goto :calculateoffset

echo Calculating the day and year diff because current_dayofyear is less than target_dayofyear.
set /a day_diff=365+%day_diff%
set /a year_diff-=1
goto :calculateoffset



:calculateoffset
echo Calculating the offset for %year_diff% year(s) and %day_diff% day(s) back.

REM We calculate in seconds and add 3 zeros in the argument to overcome the problem of not being able to create integers greater than 32 bit.
REM The value of the month is the year seconds devided by 12, so this is not exact.
REM 1 year in seconds: 365,25*24*60*60 = 31557600 sec
set year_seconds=31557600
set day_seconds=86400

set /a timeoffset=%year_diff%*%year_seconds%
set /a timeoffset+=%day_diff%*%day_seconds%
set /a timeoffset=%timeoffset%*-1
set timeoffset_milliseconds=%timeoffset%000

echo Setting the virtualbox %vmname% with an offset of %timeoffset_milliseconds% msec.
%vboxmanage% modifyvm %vmname% --biossystemtimeoffset %timeoffset_milliseconds%

echo Starting the virtual machine %vmname%.
%vboxmanage% startvm %vmname%

goto :eof
Is win8 different somehow when it comes to running Vboxmanage.exe files?

Thanks for any help


Update:

Looks like win8 doesn`t like space between letters in VB name. Changed "win7 64u" to "win7" and now i get this "error"