Jump to content

TrueCrypt UDFs


FuryCell
 Share

Recommended Posts

These UDFs give the ability to mount and unmount truecrypt volumes from a script. They are simply wrappers for the command line interface of TrueCrypt.

Download

Edited by P5ych0Gigabyte
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

  • 5 months later...

Modified to work with 64 bit

;V0.1.2A
#include-Once

;Gets or sets the path of the TrueCrypt executable (only needed if truecrypt is installed to a different path)
Func _TC_Path($sPath = "")
if @OSArch = "X32" Then
    Static $sTCPath = @ProgramFilesDir & "\TrueCrypt\TrueCrypt.exe"
Else
    Static $sTCPath = @HomeDrive&"\Program Files (x86)\TrueCrypt\TrueCrypt.exe"
EndIf

    Switch $sPath
        Case ""
            Return $sTCPath
        Case Else
            $sTCPath = $sPath
    EndSwitch
EndFunc   ;==>_TC_Path

;Mounts a TrueCrypt volume
;@Error=1: $sVol POSSIBLY does not exist or is a directory
;@Error=2: $cLetter was not valid (must be in the format "E" not "E:" or "E:\")
;Return 1:Success
;Return 0:Failure
Func _TC_Mount($sVol, $cLetter, $sPassword = "")
    If Not FileExists($sVol) Then SetError(1, 0, 0)
    If StringInStr(FileGetAttrib($sVol), "D") Then SetError(1, 0, 0)

    If StringLen($cLetter) <> 1 Then Return SetError(2, 0, 0)
    If Not StringIsAlpha($cLetter) Then Return SetError(2, 0, 0)

    Switch $sPassword
        Case ""
            Return ShellExecuteWait( _TC_Path() & '" /q /v "' & $sVol & '" /l' & $cLetter)
        Case Else
            Return ShellExecute(_TC_Path(), ' /q /s /p "' & $sPassword & '" /v "' & $sVol & '" /l' & $cLetter)
    EndSwitch
EndFunc   ;==>_TC_Mount

;Unmounts a TrueCrypt Volume
;@Error=1: $cLetter was not valid (must be in the format "E" not "E:" or "E:\")
;@Error=2: $iForce was not valid (must be 0 or "1)
;Return 1:Success
;Return 0:Failure
Func _TC_UnMount($cLetter, $iForce = 0)
    If StringLen($cLetter) <> 1 Then Return SetError(1, 0, 0)
    If Not StringIsAlpha($cLetter) Then Return SetError(1, 0, 0)
    If Not ($iForce = 0 Or $iForce = 1) Then Return SetError(2, 0, 0)

    Switch $iForce
        Case 1
            Return Not RunWait('"' & _TC_Path() & '" /s /q  /f /d' & $cLetter)
        Case 0
            Return Not RunWait('"' & _TC_Path() & '" /s /q /d' & $cLetter)
    EndSwitch
EndFunc   ;==>_TC_UnMount

[center][/center][center]=][u][/u][/center][center][/center]

Link to comment
Share on other sites

Well when running in script form when on 64 bit or compiled to 64 bit, it needs these modifications to work.

I also changed run to shellexecute, to make sure the truecrypt exe exists.

[center][/center][center]=][u][/u][/center][center][/center]

Link to comment
Share on other sites

Well when running in script form when on 64 bit or compiled to 64 bit, it needs these modifications to work.

I also changed run to shellexecute, to make sure the truecrypt exe exists.

How does changing to shellexecute make a difference? Can't you just check the return value of run?

Edited by FuryCell
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

It was using that method, but the function would successfully complete without any sign of error.

Also, using shell execute with the parameters to pass cmdline params to the exe is more reliable.

[center][/center][center]=][u][/u][/center][center][/center]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...