help - run all exe files in a directory

Discuss RoboTask here
Post Reply
zlatch
Posts: 4
Joined: Sat Sep 27, 2008 6:46 pm

help - run all exe files in a directory

Post by zlatch »

I need to create a task that runs all the .exe files in a given directory, one at a time. How is that done?
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

help - run all exe files in a directory

Post by Oleg »

No problem. Use "File loop" action.

algorithm is simple:

file loop by *.exe
Run program // current exe
end loop

see the example below:

;*****************************
;* RoboTask Task file       
;* Do not edit in text editor!
;*****************************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1961495446
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task28"
Hide=INTEGER|0
ID=INTEGER|631548151
Name=STRING|"File Loop..."
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER

[Actions\Action1]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action1\Params]
createmode=STRING|"1"
date1=STRING|"20080928"
date2=STRING|"20080928"
destvar=STRING|"C_EXE"
DuringDays=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"C:\incoming\*.exe"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""{c_exe} """
Params=FOLDER

[Actions\Action2\Params]
program=STRING|"{c_exe}"
runas=STRING|"0"
wait=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
zlatch
Posts: 4
Joined: Sat Sep 27, 2008 6:46 pm

help - run all exe files in a directory

Post by zlatch »

Ok, maybe my problem is a bit more complex:The files I'm trying to open automatically are .exe self-extracting files created by 7-zip. As such, they are unsigned, and windows pops up a warning asking me whether I want to run them, b/c they are untrusted.I've tried to create the following (I'll post the code in after):Step 1 - File loop by .exe, assigning the name of the current file to a variableStep 2 - run the file, using the variable from step 1 to identify itStep 3 - Focus on the window that pops upStep 4 - Send keystrokes to that window to tell it to run the file.Step 5 - End loopI've tried a few ways, but when I run the task, it opens the exe file, but it unable to communicate with the dialogue box that pops up. Here's the code, any suggestions?;*****************************;* RoboTask Task file         ;* Do not edit in text editor!;***************************** [Root]ActionAfterRun=INTEGER|0Actions=FOLDERAutomat=INTEGER|-1CatID=INTEGER|385352816ContinueOnError=INTEGER|0ExternalName=STRING|"Task1"Hide=INTEGER|0ID=INTEGER|325164413Name=STRING|"File Loop..."Priority=INTEGER|3RunOnClose=INTEGER|0RunOnStartup=INTEGER|0ToLog=INTEGER|3WriteGeneralLog=INTEGER|0[Actions]Action1=FOLDERAction2=FOLDERAction3=FOLDERAction4=FOLDERAction5=FOLDER[Actions\Action1]ActionID=STRING|"A_LOOP_FILE"Enabled=INTEGER|-1Name=STRING|"File Loop"Params=FOLDER[Actions\Action1\Params]createmode=STRING|"1"date1=STRING|"20080928"date2=STRING|"20080928"destvar=STRING|"FRET"DuringDays=STRING|"1"DuringMonths=STRING|"1"file0=STRING|"C:\Program Files\Frets on Fire\data\songs\*.exe"filecount=STRING|"1"OlderDays=STRING|"1"OlderMonths=STRING|"1"savesize=STRING|"0"searchkind=STRING|"0"subdirs=STRING|"1"timesize=STRING|"0"WithoutPath=STRING|"0"[Actions\Action2]ActionID=STRING|"A_GENERAL_RUN_PROG"Enabled=INTEGER|-1Name=STRING|"Run ""{FRET} """Params=FOLDER[Actions\Action2\Params]program=STRING|"{FRET}"runas=STRING|"0"wait=STRING|"0"[Actions\Action3]ActionID=STRING|"A_WINDOW_COMMAND"Enabled=INTEGER|-1Name=STRING|"Focus window ""Open File - Security Warning"""Params=FOLDER[Actions\Action3\Params]action=STRING|"0"caption=STRING|"1"child=STRING|"0"class=STRING|"0"classexact=STRING|"0"exact=STRING|"0"findmode=STRING|"0"hidden=STRING|"0"processall=STRING|"0"wincaption=STRING|"Open File - Security Warning"[Actions\Action4]ActionID=STRING|"A_GENERAL_SENDKEYS"Enabled=INTEGER|-1Name=STRING|"Send keys to active window"Params=FOLDER[Actions\Action4\Params]currentwindow=STRING|"1"fixedwindow=STRING|"1"keylayout=STRING|"67699721"keys=STRING|"{TAB}{TAB}{TAB}{ENTER}"sendkind=STRING|"0"wincaption=STRING|"Open File - Security Warning"[Actions\Action5]ActionID=STRING|"A_LOOP_END"Enabled=INTEGER|-1Name=STRING|"End Loop"
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

help - run all exe files in a directory

Post by Oleg »

I think you have to do this

1. Insert some pause after running of program
2. Insert "Wait for process" into end of the loop. Specify {FRET} as process name.
zlatch
Posts: 4
Joined: Sat Sep 27, 2008 6:46 pm

help - run all exe files in a directory

Post by zlatch »

I tried your suggestions, but without success. According to the log, the task fails on Step 1 (Run "{FRET}") - because I click cancel when I'm prompted by my security warning. For whatever reason, Robotask is not running the next step, even though I'm telling it not to wait.Any thoughts?
zlatch
Posts: 4
Joined: Sat Sep 27, 2008 6:46 pm

help - run all exe files in a directory

Post by zlatch »

OK - I changed my security settings so that this prompt doesn't come up, and I took out some of the steps in the task. Now I've got a new problem - my file loop keeps running the same file over and over again.;*****************************;* RoboTask Task file         ;* Do not edit in text editor!;***************************** [Root]ActionAfterRun=INTEGER|0Actions=FOLDERAutomat=INTEGER|-1CatID=INTEGER|385352816ContinueOnError=INTEGER|0ExternalName=STRING|"Task1"Hide=INTEGER|0ID=INTEGER|325164413Name=STRING|"File Loop..."Priority=INTEGER|3RunOnClose=INTEGER|0RunOnStartup=INTEGER|0ToLog=INTEGER|3WriteGeneralLog=INTEGER|0[Actions]Action1=FOLDERAction2=FOLDERAction3=FOLDERAction4=FOLDER[Actions\Action1]ActionID=STRING|"A_LOOP_FILE"Enabled=INTEGER|-1Name=STRING|"File Loop"Params=FOLDER[Actions\Action1\Params]createmode=STRING|"1"date1=STRING|"20080928"date2=STRING|"20080928"destvar=STRING|"FRET"DuringDays=STRING|"1"DuringMonths=STRING|"1"file0=STRING|"C:\Program Files\Frets on Fire\data\songs\*.exe"filecount=STRING|"1"OlderDays=STRING|"1"OlderMonths=STRING|"1"savesize=STRING|"0"searchkind=STRING|"0"subdirs=STRING|"1"timesize=STRING|"0"WithoutPath=STRING|"0"[Actions\Action2]ActionID=STRING|"A_GENERAL_RUN_PROG"Enabled=INTEGER|-1Name=STRING|"Run ""{FRET} """Params=FOLDER[Actions\Action2\Params]program=STRING|"{FRET}"runas=STRING|"3"wait=STRING|"0"[Actions\Action3]ActionID=STRING|"A_GENERAL_SENDKEYS"Enabled=INTEGER|-1Name=STRING|"Send keys to active window"Params=FOLDER[Actions\Action3\Params]currentwindow=STRING|"1"fixedwindow=STRING|"1"keylayout=STRING|"67699721"keys=STRING|"{ENTER}"sendkind=STRING|"0"wincaption=STRING|"Open File - Security Warning"[Actions\Action4]ActionID=STRING|"A_LOOP_END"Enabled=INTEGER|-1Name=STRING|"End Loop"
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

help - run all exe files in a directory

Post by Oleg »

See my edition of the task below:

;*****************************
;* RoboTask Task file       
;* Do not edit in text editor!
;*****************************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|1076699455
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task712"
Hide=INTEGER|0
ID=INTEGER|1271818381
Name=STRING|"Run each EXE and wait for exit"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER

[Actions\Action1]
ActionID=STRING|"A_LOOP_FILE"
Enabled=INTEGER|-1
Name=STRING|"File Loop"
Params=FOLDER

[Actions\Action1\Params]
createmode=STRING|"1"
date1=STRING|"20080928"
date2=STRING|"20080928"
destvar=STRING|"FRET"
DuringDays=STRING|"1"
DuringMonths=STRING|"1"
file0=STRING|"C:\Program Files\Frets on Fire\data\songs\*.exe"
filecount=STRING|"1"
OlderDays=STRING|"1"
OlderMonths=STRING|"1"
savesize=STRING|"0"
searchkind=STRING|"0"
subdirs=STRING|"1"
timesize=STRING|"0"
WithoutPath=STRING|"0"

[Actions\Action2]
ActionID=STRING|"A_GENERAL_RUN_PROG"
Enabled=INTEGER|-1
Name=STRING|"Run ""{FRET} """
Params=FOLDER

[Actions\Action2\Params]
program=STRING|"{FRET}"
runas=STRING|"3"
wait=STRING|"0"

[Actions\Action3]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay 500 ms"
Params=FOLDER

[Actions\Action3\Params]
delay=STRING|"5"

[Actions\Action4]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Send keys to active window"
Params=FOLDER

[Actions\Action4\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"1"
keylayout=STRING|"67699721"
keys=STRING|"{ENTER}"
sendkind=STRING|"0"
wincaption=STRING|"Open File - Security Warning"

[Actions\Action5]
ActionID=STRING|"A_WAITFORPROCESS"
Enabled=INTEGER|-1
Name=STRING|"Wait for ""{FRET}"" (120 sec.)"
Params=FOLDER

[Actions\Action5\Params]
assign=STRING|"0"
infinity=STRING|"0"
more=STRING|"0"
process=STRING|"{FRET}"
timeout=STRING|"120"

[Actions\Action6]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
Post Reply