CODE
@Echo Off
:: just a simple batch file created by CWorks, edited by cquirke
:: 0x100000 = 1M
:: 0x20000000 = 512M
SetLocal
If "%ramdrv%"=="" Exit /b 4
If Not Defined ramdrv Exit /b 3
If Not Defined ramdrv Exit
If Not "%SystemDrive%"=="%~d0" Exit /b 2
If "%SystemDrive%"=="C:" Exit /b 1
Set Dec=%1
If Not "%1"=="" GoTo SkipMenu
:Menu
Title=[ RAM Disk ] Choose Size
Color 70
Cls
Echo.
Set Dec=
Set /P Dec= Enter desired RAM disk size in Megs (or W to wipe):
:SkipMenu
If /I "%Dec%"=="W" GoTo Wipe
If Not "%Dec:~4%"=="" GoTo Menu
Set Test=%Dec%
:Check
Set Digit=%Test:~0,1%
Set Test=%Test:~1,4%
Set Hex=N
For %%n In (0 1 2 3 4 5 6 7 8 9) Do (
If "%Digit%"=="%%n" Set Hex=Y
)
If "%Hex%"=="N" GoTo Menu
If Not "%Test%"=="" GoTo Check
Set Test=%Dec%
Set Hex=h
:Next
Set /A Left=Test/16
Set /A Digit=Test-Left*16
Set /A Test=Left
If "%Digit%"=="15" Set Digit=F
If "%Digit%"=="14" Set Digit=E
If "%Digit%"=="13" Set Digit=D
If "%Digit%"=="12" Set Digit=C
If "%Digit%"=="11" Set Digit=B
If "%Digit%"=="10" Set Digit=A
Set Hex=%Digit%%Hex%
If Not "%Test%"=="0" GoTo Next
If "%Hex%"=="" GoTo Menu
:Apply
Set Hex=0x%Hex:~,-1%00000
Echo.
Echo RAM drive to be wiped and set to %Dec%M (%Hex%)
REG.exe ADD HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Ramdriv\Parameters /f /v DiskSize /t REG_DWORD /d %Hex%
:Wipe
Color 7C
Echo.
Title Initializing RAM drive...
Echo Please wait while the RAM drive is initialized...
Echo.
%SystemRoot%\System32\Devcon disable ramdriv
%SystemRoot%\System32\Devcon enable ramdriv
Echo.
Echo ...OK
Echo.
Title Initializing RAM drive... done!
Color 78
:End
EndLocal
:: just a simple batch file created by CWorks, edited by cquirke
:: 0x100000 = 1M
:: 0x20000000 = 512M
SetLocal
If "%ramdrv%"=="" Exit /b 4
If Not Defined ramdrv Exit /b 3
If Not Defined ramdrv Exit
If Not "%SystemDrive%"=="%~d0" Exit /b 2
If "%SystemDrive%"=="C:" Exit /b 1
Set Dec=%1
If Not "%1"=="" GoTo SkipMenu
:Menu
Title=[ RAM Disk ] Choose Size
Color 70
Cls
Echo.
Set Dec=
Set /P Dec= Enter desired RAM disk size in Megs (or W to wipe):
:SkipMenu
If /I "%Dec%"=="W" GoTo Wipe
If Not "%Dec:~4%"=="" GoTo Menu
Set Test=%Dec%
:Check
Set Digit=%Test:~0,1%
Set Test=%Test:~1,4%
Set Hex=N
For %%n In (0 1 2 3 4 5 6 7 8 9) Do (
If "%Digit%"=="%%n" Set Hex=Y
)
If "%Hex%"=="N" GoTo Menu
If Not "%Test%"=="" GoTo Check
Set Test=%Dec%
Set Hex=h
:Next
Set /A Left=Test/16
Set /A Digit=Test-Left*16
Set /A Test=Left
If "%Digit%"=="15" Set Digit=F
If "%Digit%"=="14" Set Digit=E
If "%Digit%"=="13" Set Digit=D
If "%Digit%"=="12" Set Digit=C
If "%Digit%"=="11" Set Digit=B
If "%Digit%"=="10" Set Digit=A
Set Hex=%Digit%%Hex%
If Not "%Test%"=="0" GoTo Next
If "%Hex%"=="" GoTo Menu
:Apply
Set Hex=0x%Hex:~,-1%00000
Echo.
Echo RAM drive to be wiped and set to %Dec%M (%Hex%)
REG.exe ADD HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Ramdriv\Parameters /f /v DiskSize /t REG_DWORD /d %Hex%
:Wipe
Color 7C
Echo.
Title Initializing RAM drive...
Echo Please wait while the RAM drive is initialized...
Echo.
%SystemRoot%\System32\Devcon disable ramdriv
%SystemRoot%\System32\Devcon enable ramdriv
Echo.
Echo ...OK
Echo.
Title Initializing RAM drive... done!
Color 78
:End
EndLocal
Features are:
- can be driven via command line parameters (easier to GUI)
- accepts decimal size, e.g. 512 for 512M
- accepts W as parameter to wipe the RAM drive without resize
