@set @x=0; /*
@echo off
ver |>NUL find /v "5." && if "%~1"=="" cscript.exe //nologo //e:jscript "%~f0"& exit /b
@Findstr -bv ;@ "%~f0" | powershell -WindowStyle hidden -noprofile -command - & goto:eof
# All except ;@ is a powershell script!
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding("utf-8")
# Config parameters #
# Path of the VBoxManage executable.
$VB_MANAGE ="C:\Program Files\Oracle\VirtualBox\VBoxManage"
# Name or uuid of the virtualbox to start.
$vmname ='Kirisun-DS5800-server'
# Default BIOS time dd/mm/yyyy
$BIOStime = '08/01/2023'
function CustomInputBox([string] $title, [string] $message, [string] $defaultText) {
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$userForm = New-Object System.Windows.Forms.Form
$userForm.Text = "$title"
$userForm.Size = New-Object System.Drawing.Size(400,150)
$userForm.StartPosition = "CenterScreen"
$userForm.AutoSize = $False
$userForm.MinimizeBox = $False
$userForm.MaximizeBox = $False
$userForm.SizeGripStyle= "Hide"
$userForm.WindowState = "Normal"
$userForm.FormBorderStyle="Fixed3D"
$userForm.ShowInTaskBar = $False
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Size(115,80)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = "OK"
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$userForm.AcceptButton = $OKButton
$userForm.Controls.Add($OKButton)
$OKButton.tabindex = 1
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(195,80)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$userForm.CancelButton = $CancelButton
$userForm.Controls.Add($CancelButton)
$CancelButton.tabindex = 2
$userLabel = New-Object System.Windows.Forms.Label
$userLabel.Location = New-Object System.Drawing.Size(20,20)
$userLabel.Size = New-Object System.Drawing.Size(400,20)
$userLabel.Text = "$message"
$userForm.Controls.Add($userLabel)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(150,45)
$objTextBox.Size = New-Object System.Drawing.Size(100,40)
$objTextBox.Text="$defaultText"
$userForm.Controls.Add($objTextBox)
$objTextBox.tabindex = 0
$userForm.Topmost = $True
$userForm.Opacity = 1
$userForm.ShowIcon = $False
$userForm.Add_Shown({$userForm.Activate(); $objTextBox.Focus()})
$dialogResult = $userForm.ShowDialog()
if ($dialogResult -eq [System.Windows.Forms.DialogResult]::OK) { $objTextBox.Text }
$userForm.dispose() }
do {
$title = "Input BIOS date for VM $vmname"
$msg = "Enter new BIOS date in the format of dd/mm/yyyy:"
$reply = CustomInputBox $title $msg $BIOStime
if($reply.Length -eq 0) { exit }
$date = ($reply + " " + [datetime]::Now.ToShortTimeString()) -as [datetime]
if (!$date) { $shell = new-object -comobject "WScript.Shell"
$shell.popup("Date is not in a valid format",0,"Syntax error",0+48+4096) }
} while ($date -isnot [datetime])
start-process $VB_MANAGE setextradata, $vmname, 'VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled 1' -NoNewWindow
$timeoffset_milliseconds='{0:0}' -f ([datetime]$date - [datetime]::Now).TotalMilliseconds
$shell = new-object -comobject "WScript.Shell"
$date2 = Get-Date($date) -UFormat "%d/%m/%Y"
$result = $shell.popup("Do you want to set the BIOS time of $vmname to dd/mm/yyyy where is $date2 wich equals an offset of $timeoffset_milliseconds msec from current time and start the virtual machine?",0,"Verify action for VM $vmname",4+32+4096)
# $result will be 6 for yes, 7 for no.
if ($result -eq 7) { exit }
start-process $VB_MANAGE modifyvm, $vmname, '--biossystemtimeoffset', $timeoffset_milliseconds -NoNewWindow
echo "Starting virtual machine $vmname"
start-process $VB_MANAGE startvm, $vmname
pause
exit /B
:: Эту строку не трогать. Ниже ничего не писать!!!
*/new ActiveXObject('Shell.Application').ShellExecute (WScript.ScriptFullName,'Admin','','runas',1);