Fix the Dataram RAMDisk driver letter – with sample scripts

[Note: 我們另外為此文章撰寫了中文版本,請看這篇。]


Since I wrote the post of Fixing the drive letter for RAMDisk without saving and loading drive image – A solution for Dataram RAMDisk, I received more response than I expected. From all the response, I find it really hard to explain without real sample scripts. So now I’m try to solve it by showing a sample script.

This post is supposed to give supplementary information about the original post. If you want to know more about the idea and technical details, you’re highly recommended to read the original post.

In this post I provides two sample scripts, one for the PC startup and one for shut down. I use my own PC’s setting to demonstrate the idea. So in order to run the script in YOUR PC, you may either change your PC’s setting to fit mine or change the script to fit your PC.

Here is some important assumptions / PC settings that you may need to know before we start:

  1. It assumes the disk label for the Dataram RAMDisk is “RAMDISK” (case-sensitive)
  2. It fixes the RAMDisk drive letter as R: .
  3. It loads the files stored in C:\MyRAMDiskFiles to the R: automatically. These files are the programs that I want to run at RAMDisk for better performance. For example, I put my Firefox at C:\MyRAMDiskFiles\Programs\Firefox\Firefox.exe,  So after the script, I can always launch firefox in R:\Programs\Firefox\Firefox.exe
  4. I also have Google Chrome installed in C:\Program Files. However, Chrome will always stores its cache files in the location where it installed. This script will mount the cache folder in the Chrome’s installation path to the RAMDisk drive, i.e.  R:\TEMP\BrowserCache . This can reduce the harddisk I/O frequency, and after the PC shutdown, the cache files will be erased automatically.
  5. Since I may change the program settings over time (e.g. updating the firefox extensions), I want these changes being maintained every time I starts the PC. So I want SOME files in the RAMDisk drive be saved to harddisk when I shutdown the PC.
  6. Also, all my downloaded files are stored in RAMDisk (R:\Download), but I don’t want to lose these files after reboot. So this script will also copy the files in R:\Download to C:\Download during PC shutting down.

Let’s start

Step 1

Create the two scripts: StartUp.bat and ShutDown.bat, and store them in C:\ (or whatever you like, as you will specify the files in latter steps)

Note: Line-break has important meaning in DOS Batch script, so if you copy & paste the script from this post, you must check if there is any extra line-breaks added by the text editor. Instead, you may consider download the zipped scripts : RAMDisk fix drive letter - sample scripts (Download is recommended.)

Script 1: C:\StartUp.bat

@echo off

@rem assign the key variables, see assumption #1 & #2
SET _ramdrive=R:

@rem Find the drive letter which has volume name set as RAMDISK, and mount it to _ramdrive
FOR /F "skip=1 tokens=1 delims=: " %%a IN ('wmic logicaldisk where "VOLUMENAME='%_label%'" GET CAPTION') DO (
	subst %_ramdrive% %%a:\

@rem initialize the ramdisk - automatically copy the files in C:\MyRamDriveFiles to the ramdisk after the Windows starts. see assumption #3
mkdir %_ramdrive%\Programs
xcopy C:\MyRamDriveFiles\*.* %_ramdrive%\Programs\ /E/Q/Y/R

@rem link the google chrome cache folder to ramdisk. Remeber to replace [Your-Windows-user-name] with your own, see assumption #4
mkdir %_ramdrive%\TEMP\BrowserCache
mklink /j "C:\Users\[Your-Windows-user-name]\AppData\Local\Google\Chrome\User Data\Default\Cache" "%_ramdrive%\TEMP\BrowserCache"

@rem create a dir in ramdisk to stores the downloaded files, you will need to set up Firefox to store downloaded files in R:\Download, see assumption #6
mkdir %_ramdrive%\Download

@echo on

Script 2: C:\ShutDown.bat

@echo off

@rem see assumption #2
SET _ramdrive=R:

@rem copy all program files back to harddisk -  see assumption #5
xcopy %_ramdrive%\Programs\*.* C:\MyRamDriveFiles\ /Q/Y/R/S/D/C

@rem copy all downloaded files back to harddisk  -  see assumption #6
mkdir C:\Download
xcopy %RAMDISK%\Download\*.* C:\Download\ /S/D/Q/R/C

rem disconnect the google chrome cache folder linking -  see assumption #4
rmdir "C:\Users[Your-Windows-user-name]\AppData\Local\Google\Chrome\User Data\Default\Cache"

rem delete the drive mounting
subst %RAMDISK% /D

echo on

Step 2

Go read the original post and do step 3 in that post.

Step 3

Now you have added the StartUp.bat script to the “Group Policy Editor”, so go back to step 3.2 in the original post, repeat the step but click ok “ShutDown” instead of “StartUp”, and add the “C:\ShutDown.bat” to the list.

So now you have “C:\StartUp.bat” added to “Startup” and “C:\ShutDown.bat” added to “Shutdown”.

Startup script

Step 4

Make sure you have met the assumptions above, and check if you have all the “C:\MyRAMDiskFiles” and “C:\Download” folders created. Then restart your computer and enjoy the RAMDisk.

Comments are welcomed!

14 Replies to “Fix the Dataram RAMDisk driver letter – with sample scripts”

    1. Did you modify the downloaded script? If yes, could you pls post the modified version here?

      Also, is there any system message during the script execution?
      To see the system message, you will need to
      1. find “@echo off” and “@echo on” from the script and remove these two lines.
      2. add a new line with text “pause” at the end of the script. The “pause” command will ask user’s confirmation before closing the execution, so that user can see all the message during the execution.


  1. My mistake. It works. But Windows doesn’t always show the new mapped drive – i.e. it often just lists the non-changed drive letter. But I see that the links to the forced drive letter work!

    Thank you!!!

    1. Yes, you’re right. If there is no gpedit.msc (in Win7 Home version), you’ll have to use task scheduler or the startup folder in start menu. The startup folder is not recommanded because the script in this folder runs in a later position in the launching sequence.

    1. With the free version of Dataram RAMDisk, you can set up a RAMDisk at max. 4GB. If you want to exceed this limit, you will have to purchase a license from their website.

      Even when you have the license, the RAMDisk cannot exceed the size of your total RAM which is 8GB in your case. So it’s not possible (and actually not recommended) to put the 20GB Program Files folder into the RAMDisk. You may consider moving the programs that are frequently used or require intensive disk read/write operations to your RAMDisk. In this case, 4GB is fairly enough.

  2. Hello and thank you for the time you spend on this trick i really good and i don’t understand why dataram don’t apply it on their soft.

    I write today because i have a little problem when applying the script.

    In fact i wanted the letter B for the flash drive. So i change in the bat file and it’s work but in the windows explorer i see now 2 ramdisk drives, the B and the E (who was the original letter). Is it possible to hide the E ?

    Thanks you and i hope you understand my poor english

    1. A simple answer is Yes.

      There is a comment from Merijn (June 18, 2011 at 8:38 PM) on my another post suggesting another way to change the drive letter using disk partitioning command (diskpart).

      It seems a better solution because diskpart alters the drive letter of the RAMDisk directly, so at the end you won’t have a duplicated drive letter.

      As I didn’t test this method by myself, I can’t give much comment.

  3. Nice script… but I use this small USBDLM program from which manages all my USB drives. A small usbdlm.ini file does all I want…

    ; This is a sample for an USBDLM.INI
    ; Create a new USBDLM.INI or rename it to USBDLM.INI

    ; More informations in the help file USBDLM_ENG.CHM

    ;—————————— Settings ————————————-

    ;here you can let USBDLM remove driveletters of cardreaders as long
    ;as there is no media present

    ;here you can let USBDLM write a logfile, default is _USBDLM.LOG in
    ;the root of the Windows drive

    ;—————————- BalloonTips ————————————-
    ;this activates balloon tips and sets their show duration in milliseconds

    ;————————– the drive letters ———————————
    ;here you can define new default drive letter for USB drives

    ;here you can define drive letter that shall never be used for new local drives.
    ;configure here your network and subst drives here but no local drives!

    ;many other options are documented in the Help files

    1. Thanks for the tips. It’s interesting.

      Wondering if the tool can fix the letter for ram driver as well. It is not mentioned from the website.

  4. I have trouble getting RAMDisk to start (& run) automatically on startup.

    Could you provide include instructions to have the program run BEFORE the scripts are initialized or perhaps add the correct string into the startup.bat script?

  5. Mike,

    I just figured it out. Ramdisk does run on every restart. In order for windows to see the new RAMDISK (R) drive you must select one of the fat file systems in the settings tab. (I could not get it to work using the unformatted tab unless I used the “load image at startup” tap which defeats the purpose of the batch file.

    On your first restart after applying the fat file system you will need to go into windows disk management and assign (R) to the drive already created. The drive will now show on subsequent boots.

Leave a Reply

Your email address will not be published. Required fields are marked *