azkerm Posted October 24, 2016 Share Posted October 24, 2016 Hi There, I'm using a script that was given by one of my colleague but not sure from where he has taken. I have posted earlier about the same script having issues. Nevertheless, they are all working and what I'm trying to achieve is by adding another statement to the IF condition within the script. Actual scripts are as seen below; Mount_TC.au3 file #AutoIt3Wrapper_icon=lock.ico #include"_TC.au3" _TC_Path("C:\Program Files\TrueCrypt\TrueCrypt.exe") $result=True if DriveStatus("S:\")<> "INVALID" Then ;Check if we're already mounted $result=True else $result =_TC_Mount("C:\OFC_FILES\TrueCrypt_Container\AskerTC.tc","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:\Program Files (x86)\Dropbox\Client\Dropbox") if not $result then MsgBox(0,"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) Else MsgBox(0,"Mount Cancelled","Secure Partition has not been mounted.",1) EndIf Unmount_TC.au3 file #include"_TC.au3" _TC_Path("C:\Program Files\TrueCrypt\TrueCrypt.exe") ;$result =_TC_Mount("C:\OFC_FILES\TrueCrypt_Container\AskerTC.tc","S") ;If $result = True Then ; $result= Run ("C:\Users\asker\AppData\Roaming\Dropbox\bin\Dropbox") ; if not $result then MsgBox(0,"Dropbox Error", "Could not load Dropbox") ;EndIf $result=True $PID = ProcessExists("dropbox.exe") ; Will return the PID or 0 if the process isn't found. If $PID Then $result=ProcessClose($PID) If not $result Then MsgBox(0,"Unmount Aborted","Could not shutdown Dropbox") Else if DriveStatus("S:\")<> "INVALID" Then $result =_TC_UnMount("S",1) if not $result then MsgBox(0,"Error Unmounting","An error occured unmounting the secure drive") Else MsgBox(0,"Secure Partition Not Found","It appears as if the secure partition is not mounted",2) EndIf EndIf This basically unmount and mount the truecrypt container. On mount it starts the dropbox process if there's none as the location is within the truecrypt. Also, on dismount, it kills the dropbox process first and then unmount the container. Now what I basically need is to add Google drive on to the list. However, I'm quite confused how to add them as I tried the "and" syntax with the little knowledge I have but it did not succeed. Any advise on this will be helpful! Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted October 24, 2016 Share Posted October 24, 2016 Not sure exactly what you need, you have a few options for general If statements. You can "nest" them, you can use AND/OR and there is also CASE/SWITCH. Nested: $i = 15 If $i > 10 Then ;Do Something if true If $i > 12 Then ;Do Something Else if also true Else ;Do Something when not true EndIf EndIf And: $i = 23 If $i > 15 AND $i < 25 Then MsgBox(0, "", "Condiditon is True") EndIf Or: Same as AND but only one condition must be true to match. Etc... Link to comment Share on other sites More sharing options...
azkerm Posted October 26, 2016 Author Share Posted October 26, 2016 Thank you for the reply. Well, to be more clearer, what I would ideally need is; If $result1 = True and $result2 = True Then $PID1 = ProcessExists("dropbox.exe") ; Will return the PID or 0 if the process isn't found. $PID2 = ProcessExists("googledrivesync.exe") ; If not $PID1 and $PID2 Then $result1= Run ("C:\Program Files (x86)\Dropbox\Client\Dropbox") $result2= Run ("C:\Program Files (x86)\GoogleDrive") if not $result1 and $result2 then MsgBox(0,"Error", "Could not load DropBox",5) EndIf well my codes are super wrong, I can say as I'm pretty bad and conditions. However, above is what I need. When my code looks for truecrypt drive to mount, it checks whether the dropbox is running, if not it will launch dropbox while truecrypt containter is mounted. I needed to add google drive to the same script, so that it will launch as well. Again, on the second code to dismount the drives, it does the same.. it kills dropbox process and then dismounts the drive. hope it clears now! 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