Jump to content
Sign in to follow this  
schmelle

[SOLVED] Problem using Run Command

Recommended Posts

schmelle

Hi all,

nice to be back again.

I've got a big problem running openssl.exe from an Autoit script. I want to automate decrypting files with Autoit.

This works, but User must press one time any key:

#include <Process.au3>
 AutoItSetOption ("MustDeclareVars",0)
 Dim $OWNSSLKEY = "my_private_SSL-Key"
 Dim $SSLPATH = "C:\Program Files\OPENSSL\bin"
 Dim $keyfile = "C:\Temp\Key.txt.enc"
 Dim $decryptkeyfile = ""
 $decryptkeyfile = RunWait (@ComSpec&" /c "&"pause | "&Chr(34)&$SSLPATH&Chr(34)&"\openssl.exe enc -d -bf -in "&Chr(34)&$keyfile&Chr(34)&" -out "&Chr(34)&@WorkingDir&"\Key.txt"&Chr(34)&" -k "&$OWNSSLKEY)

This should be the reason, but nothing happens (the output file is not created):

#include <Process.au3>
 AutoItSetOption ("MustDeclareVars",0)
 Dim $OWNSSLKEY = "my_private_SSL-Key"
 Dim $SSLPATH = "C:\Program Files\OPENSSL\bin"
 Dim $keyfile = "C:\Temp\Key.txt.enc"
 Dim $decryptkeyfile = ""
 $decryptkeyfile = RunWait (@ComSpec&" /c "&Chr(34)&$SSLPATH&Chr(34)&"\openssl.exe enc -d -bf -in "&Chr(34)&$keyfile&Chr(34)&" -out "&Chr(34)&@WorkingDir&"\Key.txt"&Chr(34)&" -k "&$OWNSSLKEY)

The difference ist the "pause" command at the beginning of RunWait command after @ComSpec.

Thanks for help.

schmelle

Edited by schmelle

[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

Share this post


Link to post
Share on other sites
schmelle

Thanks for your reply.

Trying your code does not resolve my problem. The file Key.txt is not created. ;)

Any other suggestions?

BR schmelle


[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

Share this post


Link to post
Share on other sites
martin

Hi all,

nice to be back again.

I've got a big problem running openssl.exe from an Autoit script. I want to automate decrypting files with Autoit.

This works, but User must press one time any key:

#include <Process.au3>
AutoItSetOption ("MustDeclareVars",0)
Dim $OWNSSLKEY = "my_private_SSL-Key"
Dim $SSLPATH = "C:\Program Files\OPENSSL\bin"
Dim $keyfile = "C:\Temp\Key.txt.enc"
Dim $decryptkeyfile = ""
$decryptkeyfile = RunWait (@ComSpec&" /c "&"pause | "&Chr(34)&$SSLPATH&Chr(34)&"\openssl.exe enc -d -bf -in "&Chr(34)&$keyfile&Chr(34)&" -out "&Chr(34)&@WorkingDir&"\Key.txt"&Chr(34)&" -k "&$OWNSSLKEY)

This should be the reason, but nothing happens (the output file is not created):

#include <Process.au3>
AutoItSetOption ("MustDeclareVars",0)
Dim $OWNSSLKEY = "my_private_SSL-Key"
Dim $SSLPATH = "C:\Program Files\OPENSSL\bin"
Dim $keyfile = "C:\Temp\Key.txt.enc"
Dim $decryptkeyfile = ""
$decryptkeyfile = RunWait (@ComSpec&" /c "&Chr(34)&$SSLPATH&Chr(34)&"\openssl.exe enc -d -bf -in "&Chr(34)&$keyfile&Chr(34)&" -out "&Chr(34)&@WorkingDir&"\Key.txt"&Chr(34)&" -k "&$OWNSSLKEY)

The difference ist the "pause" command at the beginning of RunWait command after @ComSpec.

Thanks for help.

schmelle

Instead of RunWait, test your script but using ConsoleWrite or MsgBox and then you will be able to see what is wrong.

MsgBox( 0,"result is", @ComSpec&" /c "&Chr(34)&$SSLPATH&Chr(34)&"\openssl.exe enc -d -bf -in "&Chr(34)&$keyfile&Chr(34)&" -out "&Chr(34)&@WorkingDir&"\Key.txt"&Chr(34)&" -k "&$OWNSSLKEY)


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
schmelle

Hi Martin, I've ckecked this before with MsgBox.

It seems that there is a timing problem within the "Run.." Commands. I think that the command is sent before cmd.exe is ready to accept input. I tried it out with Run, RunWait and _RunDOS. Nothing works as expected.

Then I tried it out was using a "dummy" command at first and then it works as expected. ;)

$decryptkeyfile = _RunDOS (@ComSpec&" /c "&"path | "&Chr(34)&$SSLPATH&Chr(34)&"\openssl.exe enc -d -bf -in "&Chr(34)&$keyfile&Chr(34)&" -out "&Chr(34)&@WorkingDir&"\Key.txt"&Chr(34)&" -k "&$OWNSSLKEY)

Why ever it works now. Should I file a Bug Report?

Thanks and BR

schmelle


[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.