I would like my TrueCrypt virtual drive to act as a newly inserted USB drive or CD/DVD by executing commands in the partition's autorun.inf file.

I've read several suggestions online including creating a .bat file or installing software so Windows will think this is a CD, but I'd like to know the easiest and least intrusive way to pull it off. i.e. I want to keep from installing or messing with the host computer as much as possible, as this is intended to be a fully portable drive.

EDIT: To clarify, I technically have TWO separate autorun.inf files on my flash drive: there is one in the base directory of the USB drive which correctly prompts me to run TrueCrypt as soon as I insert the drive, and there is a second autorun.inf that is inside the encrypted container.

The second autorun.inf file resides in the base directory of the virtual drive created after TrueCrypt mounts (actually, this inf file was created by LiberKey, which is the portable UI I'm using inside the container). I would like to be able to autorun this second inf file as soon as the virtual drive is mounted.


There is an answer here:


Seems to be an easy way to do it. Just create a file, place the code from article into it and modify drive letter if needed. Shouldn't take more than 5 minutes.

| improve this answer | |
  • 1
    Although this information is helpful for those who may have autorun issues after inserting the USB drive, my question is actually concerning what happens AFTER the drive has been inserted and TrueCrypt has mounted the virtual drive. – NoCatharsis Mar 15 '10 at 19:23
  • This shouldn't be voted as best answer then. – Mateng Nov 19 '15 at 9:20

I know this question is old, but it is high on the search listing so I though I would post my solution.

I mount the disk and launch my programs using a .bat file. I launch the .bat file in scheduled tasks "at logon".

Here is my bat. Enjoy.

Note, you should set truecrypt to not automatically mount your "favourites" and there is a situtation that the following bat does not handle: When a volume is mounted to an alternate drive letter than specified.

REM - Truecrypt mount and launch file - 2013
REM - Set variables as needed below

SET tcexec="%PROGRAMFILES%\truecrypt\truecrypt.exe"
SET mountdrive=x
SET volumefolder="%USERPROFILE%\truecrypt"
SET volumename=TrueCrypt-Volume

IF EXIST %mountdrive%: goto DriveExists

IF NOT EXIST %volumefolder%\%volumename% goto NoVolume

IF NOT EXIST %tcexec% goto noTC

REM Mount volume
cd %volumefolder%
%tcexec% /v %volumename% /l%mountdrive% /a /q
if ERRORLEVEL 1 GOTO mountfail
if ERRORLEVEL 0 GOTO startprograms

REM ******************************
REM ** Start your programs here **
REM ******************************
REM start "" "C:\Users\<userid>\AppData\Roaming\AeroFSExec\aerofs.exe"
REM start "" "C:\Program Files\ownCloud\owncloud.exe"

REM ********************************
REM ** END of Program Start block **
REM ********************************

goto end

echo Truecrypt failed to mount volume.
goto end

echo Cant find truecrypt at: %tcexec%
goto end

echo Identified volume does not exist: %volumefolder%\%volumename%
goto end

echo Drive letter %mountdrive% already exists, cannot mount truecrypt volume
goto end

| improve this answer | |

Microsoft has a utility (aka "PowerToy") for Windows called TweakUI that allows you to enable or disable autoplay on your drives (under My Computer | Autoplay | Drives in the left pane of the TweakUI program). I just mounted a TrueCrypt volume and it's visible in TweakUI -- so it looks like I could autoplay on enable it). Sorry I can't test it further because I don't have an autorun.inf file to play with).

| improve this answer | |

In a .bat file you can call to anothr .bat file as simply as (just see the line that starts with CALL):

MyBat1.bat file has this text:


ECHO Here i will do things, like mount the .tc file

REM Here would go the command to mount the .tc file as drive letter X:

ECHO I am going to call to another bat script

CALL X:\MyBatFile_InsideTheTC.bat

ECHO I can do more things after thet other script runs

X:\MyBatFile_InsideTheTC.bat has this text:


START "WhatEverTitleYouWant" "X:\MyDirectAccess.lnk"

... and so on ...

X:\MyDirectAccess.lnk is a file created by windows when you create a shotcut to a program, also can be any command you wish like starting services, etc... i put the example of a .lnk since that .lnk can be configured (on properties) to run with elevated privileges, so it ask user for such elevation, an is a very easy way to run services after mounting a tc volume

This is also valid for VeraCrypt (succesor of TrueCrypt that uses the source code of TrueCrypt).

Example: Have the Web server (Apache) data (htdoc) folder inside the .tc file (.hc for VeraCrypt), Apache service must be set to manual start, and only after mount the .tc file the service can be started by [net star "Apache24"].

This config is for non portable Apache, since portable Apache would have no service and starts with a command, but gives a good idea of what high-level can be done.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.