azkerm Posted February 17, 2014 Share Posted February 17, 2014 (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 expandcollapse popup;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 February 17, 2014 by azkerm Link to comment Share on other sites More sharing options...
somdcomputerguy Posted February 17, 2014 Share Posted February 17, 2014 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. Link to comment Share on other sites More sharing options...
azkerm Posted February 17, 2014 Author Share Posted February 17, 2014 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") Link to comment Share on other sites More sharing options...
orbs Posted February 17, 2014 Share Posted February 17, 2014 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. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
azkerm Posted February 17, 2014 Author Share Posted February 17, 2014 (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 February 17, 2014 by azkerm Link to comment Share on other sites More sharing options...
Solution orbs Posted February 17, 2014 Solution Share Posted February 17, 2014 call _TC_Path("X:PATHTrueCrypt.exe") after the line: #include"_TC.au3" note: change X:PATH to wherever your TrueCrypt.exe is found. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
azkerm Posted February 17, 2014 Author Share Posted February 17, 2014 (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 February 17, 2014 by azkerm Link to comment Share on other sites More sharing options...
orbs Posted February 17, 2014 Share Posted February 17, 2014 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. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
azkerm Posted February 17, 2014 Author Share Posted February 17, 2014 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now