Starbeamrainbowlabs

Stardust
Blog


Archive

Mailing List Articles Atom Feed Comments Atom Feed Twitter

Tag Cloud

3d account algorithms announcement archives arduino artificial intelligence assembly async audio bash batch blog bookmarklet booting c sharp c++ challenge chrome os code codepen coding conundrums coding conundrums evolved command line compiling css dailyprogrammer debugging demystification distributed computing downtime embedded systems encryption es6 features event experiment external first impressions future game github github gist graphics hardware meetup holiday html html5 html5 canvas interfaces internet io.js jabber javascript js bin labs learning library linux low level lua maintenance network networking node.js operating systems performance photos php pixelbot portable privacy programming problems project projects prolog protocol pseudo 3d python reddit reference release releases resource review rust secrets security series list server servers software sorting source code control svg technical terminal textures three thing game three.js tool tutorial twitter ubuntu university update upgrade version control visual web website windows windows 10 xmpp

Creating new Ramdisks Programatically with Imdisk

For a while now I have used Imdisk to create ramdisks to store data temporarily while I experiment with it. Imdisk is a driver for windows systems that allows you to create virtual drives that are stored either in memory, or in a file on your hard drive. It also allows you to mount existing images stored in iso or img files to let you explore their contents, for example.

Mounting a new ramdisk with Imdisk

Since I use ramdisks so often, I have written a batch script that automates the process of creating a ramdisk, and I thought that I would share it here:

@echo off

:: BatchGotAdmin7
:: From http://stackoverflow.com/a/10052222/1460422
:-------------------------------------
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"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B

:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------

echo Ramdisk creation script

title Ramdisk Creation

set /p drive_letter=Enter Drive Letter:

if "%drive_letter%"=="" ( set drive_letter=R )

if exist %drive_letter%: (
echo A disk already exists with the letter %drive_letter%:.
echo Please unmount it before using this script.
)

set /p size=Enter Size: 

imdisk -a -s %size% -m %drive_letter%: -p "/fs:fat32 /q /y"

pause

( Pastebin, Raw, Size: 1.16KB )

To use it, first enter the driver letter that you want to assign to the new ramdisk, and then type in the size of ramdisk you want it to create, for example 512M, or 1G. Make sure you don't pick a number that is close to or above the total amount of ram you have in your system! Imdisk grabs all the RAM it will need for the ramdisk in advance!

Art by Mythdael