Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- :: BatchGotAdmin
- :-------------------------------------
- REM --> Check for permissions
- >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
- REM --> If error flag set, we do not have admin.
- if '%errorlevel%' NEQ '0' (
- echo Requesting administrative privileges...
- goto UACPrompt
- ) else ( goto gotAdmin )
- :UACPrompt
- echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
- echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
- "%temp%\getadmin.vbs"
- exit /B
- :gotAdmin
- if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
- pushd "%CD%"
- CD /D "%~dp0"
- :--------------------------------------
- REM.-- Prepare the Command Processor
- SETLOCAL ENABLEEXTENSIONS
- SETLOCAL ENABLEDELAYEDEXPANSION
- :menuLOOP
- echo.
- echo.= Menu =================================================
- echo.
- for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menu_" "%~f0""') do echo. %%B %%C
- set choice=
- echo.&set /p choice=Make a choice or hit ENTER to quit: ||GOTO:EOF
- echo.&call:menu_%choice%
- GOTO:menuLOOP
- ::-----------------------------------------------------------
- :: menu functions follow below here
- ::-----------------------------------------------------------
- :menu_1 Mount DOS.vhd
- @echo off
- SET DiskPartScript="%TEMP%DiskpartScript.txt"
- :: You may use
- :: set /p pathtovhd=Enter path to VHD:
- :: variable to enter path to file in script or play with it as you wish
- :: Maybe make a menu with filelist?
- ECHO SELECT VDISK FILE "C:\Users\Alexander\VirtualBox VMs\DOS\DOS.vhd" > %DiskPartScript%
- ECHO ATTACH VDISK >> %DiskPartScript%
- DiskPart /s %DiskPartScript%
- TIMEOUT /T 5
- CLS
- GOTO:EOF
- :menu_2 UnMount DOS.vhd
- @echo off
- SET DiskPartScript="%TEMP%DiskpartScript.txt"
- ECHO SELECT VDISK FILE "C:\Users\Alexander\VirtualBox VMs\DOS\DOS.vhd" > %DiskPartScript%
- ECHO DETACH VDISK >> %DiskPartScript%
- DiskPart /s %DiskPartScript%
- CLS
- GOTO:EOF
Advertisement
Add Comment
Please, Sign In to add comment