Jump to content
Sign in to follow this  
PcExpert

Encrypt directory

Recommended Posts

PcExpert

Hi all,

Is it possible to let autoit encrypt a directory? And encrypt it?

Thanks!

Share this post


Link to post
Share on other sites
PsaltyDS

You might use _StringEncrypt() on the contents of the files, or use AutoIt to configure Windows EFS, but I don't think AutoIt can directly do what you described.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
PcExpert

IS there maybe another program that can encrypt directories, where autoit can control it. For example: (this is what I want to do:

Encrypt:

Run("ENCRYPTIONPROGRAM/PROGRAM.exe -e MYDIRECTORY")

Decrypt

Run("ENCRYPTIONPROGRAM/PROGRAM.exe -d MYDIRECTORY")

-e = encrypt

-d = decrypt

Share this post


Link to post
Share on other sites
PsaltyDS

IS there maybe another program that can encrypt directories, where autoit can control it. For example: (this is what I want to do:

Encrypt:

Run("ENCRYPTIONPROGRAM/PROGRAM.exe -e MYDIRECTORY")

Decrypt

Run("ENCRYPTIONPROGRAM/PROGRAM.exe -d MYDIRECTORY")

-e = encrypt

-d = decrypt

Sure, the easiest might be to just zip them up with 7-zip using it's built in encryption (or WinZip, if you have oodles of money to throw down the drain). Google up "File Encryption" and you'll have about eleventy million possibilities.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
PcExpert

Mostly all programs require admin rights what I want is something like a commandline en/decryption program that you can run from an USB stick to protect directories. So you can run it with autoit with something like this

Run("encrypt.exe -e mydir")

Share this post


Link to post
Share on other sites
SkinnyWhiteGuy

Google "TrueCrypt". Not really Directory encryption, as it emulates a whole Drive, but you get the same effect. It can be used from a USB stick no problem, no install needed (other than to get it out of the initial installer file, but you just copy the files from where it installs to your USB stick, and your all set). As far as permissions needed, I don't think you need Admin to use it, but since I always have admin, I haven't tested it for that. All I can say is try it and see.

Edit: Grammar

Edited by SkinnyWhiteGuy

Share this post


Link to post
Share on other sites
PcExpert

I've been testing it but i've decided to do not use encryption. I made a program that autoruns and then asks for a password. If the password is correct it shows the contents of the USB stick. But when you right click on the drive and then select 'OPEN' it just shows the content without first running my program. So is there a way to even let the program run if you select 'OPEN'?

Edited by PcExpert

Share this post


Link to post
Share on other sites
PsaltyDS

I've been testing it but i've decided to do not use encryption. I made a program that autoruns and then asks for a password. If the password is correct it shows the contents of the USB stick. But when you right click on the drive and then select 'OPEN' it just shows the content without first running my program. So is there a way to even let the program run if you select 'OPEN'?

The original question about encryption implies a need for security. An 'Open' dialog will provide NO security, only an annoyance to the user. What if it gets plugged in to a Mac or an Ubuntu box, or Windows box that was booted to Knoppix?

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Darkinspiration

Yes encryption :)

seriously, there is no way unless your usb stick is formated in ntfs and your user is not admin and has no permission on the content of the stick. You could then use autoit on the pc to grant right to the content of your stick.

Aldo i'm not sure if this is very portable since you might have problem using this on another windowsXP computer.

Share this post


Link to post
Share on other sites
SkinnyWhiteGuy

I've been testing it but i've decided to do not use encryption. I made a program that autoruns and then asks for a password. If the password is correct it shows the contents of the USB stick. But when you right click on the drive and then select 'OPEN' it just shows the content without first running my program. So is there a way to even let the program run if you select 'OPEN'?

After reading this, you definitely want to use TrueCrypt. Put it on the Root of the USB stick in a Folder called TrueCrypt, and run it with the following lines:

RunWait("/TrueCrypt/truecrypt.exe /q /v ../saved.pst /lo")

That will run TrueCrypt quietly, mounting the file saved.pst as another harddrive with the letter o. You'll need to create saved.pst using Truecrypt before using that, and when you create it, you will have to have a password to access the contents of that file. If they skip the password here, all they'll see on your USB stick is the saved.pst file, which won't do them any good, as it is encrypted to high heavens and back.

If you need any more help with this, PM me, and I'll work something up that I can send you. If you have a U3 compatible drive, I have an even better option for you.

Share this post


Link to post
Share on other sites
nasars

Truecrypt requires admin rights to install. On a PC without Truecrypt installed and no admin rights you won't be able to mount your drive. You may like to have a look at http://portableapps.com/node/6516

Share this post


Link to post
Share on other sites
quasimodo

I have problems in running a script using Truecrypt. The problem is, that in most - but not all cases - I have to start the script twice, e.g. I start the script, enter the Truecrypt password and then the script pauses. If I start the script again it directly opens Quicken, but the first script is still active although paused.

I have seen this since several versions of Autoscript. I tried to modify it with longer sleep commands, but nothing helps.

I enclose my little script. Hope that somebody can give me a tip.

- Wilfried

$drv=DriveStatus("X:\")

if $drv <> "READY" then

Run ("C:\Programme\TrueCrypt\Truecrypt.exe /v d:\x /lg /a /q")

Sleep (100)

Do

WinwaitActive("Enter")

WinWaitClose ("Enter")

$test = 0

$drv=DriveStatus("X:\")

if $drv <> "READY" AND WinExists("TrueCrypt") then

$test=1

endif

Until $test=0

endif

sleep(500)

$drv=DriveStatus("X:\")

if $drv <> "READY" then exit

RunWait ("X:\\QUICKEN8\\QW.EXE")

Run("c:\programme\truecrypt\truecrypt /dx /q")

Exit

Share this post


Link to post
Share on other sites
PsaltyDS

$drv=DriveStatus("X:\")

if $drv <> "READY" then 
    Run ("C:\Programme\TrueCrypt\Truecrypt.exe /v d:\x /lg /a /q")
    Sleep (100)
    Do
        WinwaitActive("Enter")
        WinWaitClose ("Enter")
        $test = 0
        $drv=DriveStatus("X:\")
        if $drv <> "READY"  AND WinExists("TrueCrypt") then
            $test=1
        endif
    Until $test=0   
endif

sleep(500)
$drv=DriveStatus("X:\")
if $drv <> "READY" then exit

RunWait ("X:\\QUICKEN8\\QW.EXE")

Run("c:\programme\truecrypt\truecrypt /dx /q")
I don't follow your usage of TrueCrypt. You keep testing the status of X:, but your command line appears to mount the encrypted volume as "G:". Quoting the TrueCrypt command line options on the options you used:

/volume or /v File and path name of a TrueCrypt volume to mount

So "/v d:\x" is mounting a TrueCrypt file at "D:\X".

/letter or /l Driver letter to mount the volume as. When /l is omitted and when /a is used, the first free drive letter is used.

So "lg" is mounting the TrueCrypt volume as "G:".

/auto or /a If no parameter is specified, automatically mount the volume.

Auotmount. Probably not required because: "Note that /auto is implicit if /quit and /volume are specified."

/quit or /q Automatically perform requested actions and exit (main TrueCrypt window will not be displayed).

Run the command line and quit. And there will be no GUI for TrueCrypt. So where are these "Enter" and "TrueCrypt" windows coming from?

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
quasimodo

@PsaltyDS

1. Sorry for my mistakes. Please read all references to drive 'x' as 'g'.

2. Yes, the '/a' command in the Truecrypt opening statement is not necessary, but also has no influence. It is overwritten by the '/l' command.

3. Quote from the Truecrypt manual: /silent or /s: If /q is specified, suppresses interaction with the user (prompts, error messages, warnings, etc.)

Without the '/q' in the command line, the Truecrypt main window is opened, with this parameter the window to insert the password is opened directly.

I have a very similar script which opens a virtual drive with my Outlook data and starts Outlook. This script is working most of the time, although I remember at least one case where I had to run the script twice too.

To repeat the problems in the Quicken script: If I boot the computer and run the script, the script pauses after opening the virtual drive 'g'. If I run it a second time, a new instance of the script will start the Quicken program. However, there is a case, where the script is running fine the first time: If after boot Quicken had started thru the script once and I stop Quicken, the program ends and the drive 'g' is dismounted as wished. So the computer seems to bee in the same state as after boot. However, if I run the script now, it works without problems. The same happens, if after boot I open and close the 'g' drive with Truecrypt once before running the script.

- Wilfried

Share this post


Link to post
Share on other sites
PsaltyDS

That Do/Until loop still makes no sense to me. What is the "Enter" window that you are looking for and closing? Is it a password window? If so, then how can it work if you close it as soon as you see it active?

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
quasimodo

This is the logical flow:

1. Reserve a constant for drive status and check if drive already exists ...

2. If virtual drive g: is not present, then create it with Truecrypt and assign drive letter g: to it

3. Wait a little bit until Truecrypt works. Truecrypt should open the window for entering the password

4.1 Enter loop: check if window with description "Enter password for d:g" opens. Now you can enter the password.

4.2 The password is checked by Truecrypt and the window "Enter.." is closed

4.3

4.4 If the password was correct, Truecrypt will install the drive g: and I can check this

4.5 but if I typed a wrong password, drive g: is not installed. In this case I set 'test' and repeat the loop

If at this point I will break the password window by clicking on 'Cancel', the script will terminate.

5. After leaving the loop I wait 500 ms because I hoped this will help AutoIt and/or Truecrypt to stabilize to be able to run the rest of the script.

Seems that exactly at this point the script pauses (mostly).

- Wilfried

Share this post


Link to post
Share on other sites
DW1

why don't you just zip/rar/7z the folder with encryption and password protection built in. And/Or you could zip/rar/7z and encrypt that file with whatever alg you like. Just food for though :whistle:

Share this post


Link to post
Share on other sites
quasimodo

why don't you just zip/rar/7z the folder with encryption and password protection built in. And/Or you could zip/rar/7z and encrypt that file with whatever alg you like. Just food for though :whistle:

1. TrueCrypt is much more save (you could even get and use the source code. No I will NOT do so), even data in tremorary storage.

2. Especially in a computer breakdown in the middle of the work, all data are safe.

3. I love it and used it since generations. And, the script is working fine with Outlook, but not with my finance program. And if it comes to finance I want be very shure.

- Wilfried

Share this post


Link to post
Share on other sites
PsaltyDS

OK, you straightened me out on part of it. I was reading your WinWaitClose as WinClose, which is not what's there:

if $drv <> "READY" then
    Run ("C:\Programme\TrueCrypt\Truecrypt.exe /v d:\x /lg /a /q")
    Sleep (100)
    Do
        WinwaitActive("Enter")
        WinWaitClose ("Enter")
        $test = 0
        $drv=DriveStatus("G:\")
        if $drv <> "READY"  AND WinExists("TrueCrypt") then
            $test=1
        endif
    Until $test=0   
endif

So, when the "Enter" window closes you have entered the password, and it will now take some time for TrueCrypt to mount the G: drive.

Now you seem to have a race condition: If the drive is not ready yet, but there is no "TrueCrypt" window open (because you used "AND"), the loop exits before the drive is mounted. If the intent is for the drive to be ready AND for the TrueCrypt window to have gone away, then you need OR in that line of code because -- you're not ready if the drive is not ready OR if the TrueCrypt window is still up.

:whistle:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×