Sign in to follow this  
Followers 0
azkerm

Launch dropbox after mounting Truecrypt

9 posts in this topic

#1 ·  Posted (edited)

Hey! All,

I'm quiet new to this & my colleague gave me a script (which hey may have obtained it over internet) which first mounts the truecrypt volume and then launch dropbox as the folder resides inside a mounted drive. I've tried tweaking the script which only launches the dropbox but does not mount the volume. I'm not too sure as to why.. Below are the scripts that I'm trying to execute.. please look into it & let me know where I made the mistake.

_TC.au3 file

;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 = "")
    Static $sTCPath = @ProgramFilesDir & "\TrueCrypt\TrueCrypt.exe"
    Switch $sPath
        Case ""
            Return $sTCPath
        Case Else
            $sTCPath = $sPath
    EndSwitch
EndFunc   ;==>_TC_Path

;Mounts a TrueCrypt volume
;@Error=1: $sVol 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 Return SetError(1, 0, 0)
    If StringInStr(FileGetAttrib($sVol), "D") Then Return 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 Not RunWait('"' & _TC_Path() & '" /q /v "' & $sVol & '" /l' & $cLetter)
        Case Else
            Return Not RunWait('"' & _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

MountTC.au3 file

#AutoIt3Wrapper_icon=lock.ico
#include"_TC.au3"


$result=True
if DriveStatus("S:\")<> "INVALID" Then ;Check if we're already mounted
    $result=True
else
    $result =_TC_Mount("c:\Users\user1\Documents\azkytest","S")
EndIf

If $result = True Then

    $PID = ProcessExists("dropbox.exe") ; Will return the PID or 0 if the process isn't found.
    If not $PID Then
        $result= Run ("C:\Users\user1\AppData\Roaming\Dropbox\bin\Dropbox")
        if not $result then MsgBox(0,"Dropbox Error", "Could not load DropBox",5)
    EndIf

    ;Restart indexing service so we pick up the TrueCrypt partition
    $result = RunWait(@ComSpec & " /c " & 'sc stop wsearch', "", @SW_HIDE)
    Sleep(3000)
    $result = RunWait(@ComSpec & " /c " & 'sc start wsearch"', "", @SW_HIDE)

    ;$result = Run(@ComSpec & " /c " & "C:\users\user1\Documents\Scripts\Restart Windows Search Indexing Task.lnk")

Else
   MsgBox(0,"Mount Cancelled","Secure Partition has not been mounted.",1)
EndIf

I'm using a 64bit operating system & I don't think this is the problem as the scripts doesn't contain any codes relating to a 32bit system. Please help me on this.

Edited by azkerm

Share this post


Link to post
Share on other sites

Are you getting any specific error messages? What are they if you are? I've noticed that in the $result = Run line (not the commented one), there is no extension at the end. Is this intentional?


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

Are you getting any specific error messages? What are they if you are? I've noticed that in the $result = Run line (not the commented one), there is no extension at the end. Is this intentional?

 

Well at first I got some errors which I don't remember. May be the error specified at MountTC.au3 file (at the end). But what I do no is that the script works as the dropbox launches while executing. What I need is the Truecrypt to be mounted before dropbox loads. If you or anyone else could tweak, I'd be happy.

Also, I'm not quiet sure what below does as I don't seem to find anything relating to that.

;$result = Run(@ComSpec & " /c " & "C:\users\user1\Documents\Scripts\Restart Windows Search Indexing Task.lnk")

Share this post


Link to post
Share on other sites

in MountTC.au3 you must call _TC_Path() to initialize the path to TrueCrypt.exe:

either _TC_Path("") if you have TrueCrypt installed - i'm not sure how this handles 32/64-bit,

or _TC_Path("X:PATHTrueCrypt.exe") where you know where X:PATH is - which i recommend.

that said, the error-checking and return value settings of _TC_Mount() are unreliable.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I'm quiet unclear on what you said. Could you please pin point as to where I should call the _TC_Path() on the script file? I'm sorry, when it comes to coding, I'm lost

Edited by azkerm

Share this post


Link to post
Share on other sites

call _TC_Path("X:PATHTrueCrypt.exe") after the line:

#include"_TC.au3"

note: change X:PATH to wherever your TrueCrypt.exe is found.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

call _TC_Path("X:PATHTrueCrypt.exe") after the line:

#include"_TC.au3"

note: change X:PATH to wherever your TrueCrypt.exe is found.

 

please correct me if I'm wrong.. it should look like below;

#AutoIt3Wrapper_icon=lock.ico
#include"_TC.au3"
_TC_Path("X:\PATH\TrueCrypt.exe")

is this right?

Edited by azkerm

Share this post


Link to post
Share on other sites

please correct me if I'm wrong.. it should look like below;

#AutoIt3Wrapper_icon=lock.ico
#include"_TC.au3"
_TC_Path("X:\PATH\TrueCrypt.exe")

is this right?

 

that is correct - but do not forget to change X:PATH to the real path where your TrueCrypt.exe is found.

Share this post


Link to post
Share on other sites

Oh my god!! you're a life saver mate.. It worked like a charm. All this time I was struggling to test _TC.au3 instead the other. I just tried both MountTC.au3 & UMountTC.au3 (which I later created) works like a charm. 

Thank you so much

Share this post


Link to post
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
Sign in to follow this  
Followers 0