Sign in to follow this  
Followers 0
maddogrsf

pass variables from a bat to an autoit exe or script

8 posts in this topic

hello  everyone and thank you in advance for the support.i m using a software called watchdirectory

i setted it to watch a folder for any newly created file

when a newly created file exist it should execute a bat

in this bat

 

notepad c:monitoreddir%wdfile_b%.%wdfile_e% (notice tha this variable is a special envirointment variable setted when the monitoring task by watchdirectory is running)

set filename=%wdfile_b%

autoitexescript.exe

 

here te autoit script goes and modify some values of the txt window

to do so i need to activate the notepad window but if the file name changes every time i can so i was thinking is it possible to  pass to autoit %filename% variable that was inside the bat and then compile the script as an exe ? if yes how ?

regards

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

In the batch file using %filename% as param should work as long as there are no spaces in the path. For that matter you could just use the environment variable directly instead of assigning it to filename.

Edited by MilesAhead

Share this post


Link to post
Share on other sites

thx for suggestion. anyway at the moment i solved this issue by a small trick. is not very professional but works !

now i will write another question !

thank you !

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

so here i am back i am at a point that my " not professional trick" is not useful for my needs here is the situation hopeing that someone can help me

so

i have this programme called watchdirectory

whenever a new event occours it can exectues several actions such as running a bat file or vbs script or exe file and so

i would like that my watchdirectory executes a bat file and i would like to know if there is the possibility that this bat file calls an autoit compiled exe and sends parameter to it

 

e.g

new file creted on c:incoming

run this bat

code of bat file

code

code code

copy %WD_FILE% d:

c:scriptmyautoitcompiledexe.exe /%WD_FILE%

echo now start auto it !

code of my autoit script prior to compiling it to exe 32 bit :

code

code

code

code

run explorer %WD_FILE%

code code code

the file name i not constant it is variable so i need that auto it exe can get this variable value from the batch file that gets it via watchdirectory enviroinment variables (%WD_FILE% is the ev to get complete file path that causes an events)

is it possible to achieve so ? if yes how ?

regards

Edited by maddogrsf

Share this post


Link to post
Share on other sites

You can use EnvGet in your script to get the environment variable's value, or you can pass that variable to your script as a command line parameter and have the script make note of this parameter. The array $CmdLine holds the parameters passed to the autoit script, and the variable $CmdLineRaw holds the string of all parameters passed to the script.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Just out of curiosity, aren't you making it more difficult on yourself than necessary by mixing and matching languages in these scripts? It seems like you would be better off investing the time in converting it all to one language (assumingly AutoIt, since you're here) which would make it both easier for you to manage and easier for the community to assist you. ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

i cant convert all to auto it that would be VERY VERY hard as watchdirectory is a very complex program that watches and monitors paths for file change  and to write a tol similar to that will be extremely hard for me !  already passing variables seems hard to me imagine write such a tool !

@

BrewManNH

can you make me an exemple code ? or point me to some manual page ? or something practical ?

 

edit: I think i found what i needed: googled the EnvGet + Autoit and got a man page ! now i know how to use it :) thank you if i will need further help i will write again here !

 

thank you !

edit 2: Ok just now tested. works like a charm :) now i can send to my autoit exe the env variable of watchdirectory using the evnget funciton i just have to declare them as globalvariables:)

Edited by maddogrsf

Share this post


Link to post
Share on other sites

Everything is also described in the help file for both the options I mentioned.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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  
Followers 0