Jump to content

Send %var value to Dos Batch or .exe


Recommended Posts

Hello everyone,

I need help to send from Autoit GUI input.text a var value to my batch...

example...

My windows batch program

set /p sourcedir=

and than

FOR /f %%a IN ('dir /b /a-d "%sourcedir%*.jpg" ') DO ( etc......

.........................

Autoit ??

Local $sourcedir= InputBox("My program", "past source path.", "")
 

This is because I would like to have a graphical user interface.
 
Thanks.

 

Link to comment
Share on other sites

You don't need a batch file.  Autoit can send commands like a console, and you can pull off the for statement in a similar manner.

That being said...

set /p sourcedir=%%1*

then when you run the batch file from within the script, just supply the $sourcedir variable as it's argument (use quotes around it).

ShellExecute ("list-pics.bat",$sourcedir,"","open",@SW_HIDE)

Link to comment
Share on other sites

You probably can replace the batch file by an AutoIt script, using functions like FileSelectFolder(), _FileListToArray(), and a loop...

For example :

#Include <File.au3>

Local $sourcedir= FileSelectFolder("Choose a folder", "", "", @ScriptDir)
If $sourcedir = "" Then Exit

Local $aFiles = _FileListToArray ( $sourcedir, "*.jpg", 1, 1)

For $i = 1 To $aFiles[0]
    ; Do wha you want with $aFiles[$i]
Next
Edited by jguinch
Link to comment
Share on other sites

Tanks,

jguinch, Tobei291

Well my program run very well inside dos shell, rewrite all .....  is very expensive!

My solution?..... easy, write one init txt file with Autoit, then read all variable from it

;explode
Local $sourcedir= FileSelectFolder("Choose a folder", "", "", @ScriptDir)
If $sourcedir = "" Then Exit
;build txt init
     FileWrite($file, $page)
     FileWrite($file, @CRLF)
     FileWrite($file, $title)
     FileWrite($file, @CRLF)
     FileWrite($file, $imgfolder)
     FileWrite($file, @CRLF)
     FileWrite($file, $descr)
     FileWrite($file, @CRLF)
     FileWrite($file,$sourcedir)
     FileClose($file)

My last question .... it is possible to run exe in hide mode?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...