Sign in to follow this  
Followers 0
StMaSi

Pass value from AutoIt script to batch file...

2 posts in this topic

If I am using a RunWait command to launch a batch file from within an AutoIt script, how can I pass a variable to said batch file so that the batch file can utilize said variable like in a %var% format? Thank you in advance.

Share this post


Link to post
Share on other sites



You can use the EnvSet function to create a variable that can be referenced from the batch file as long as the batch is spawned from the same script.

Crude example:

EnvSet("testvar","Oh Yeah!")
Run(@ComSpec & " /k echo %testvar%")

 

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

  • Similar Content

    • Miliardsto
      By Miliardsto
      Im creating a tab
      Global $Tab1 = GUICtrlCreateTab(30, 30, 600, 420, $TCS_BUTTONS, -1) And what we see in the function reference:
      https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateTab.htm
      GUICtrlCreateTab ( left, top [, width [, height [, style = -1 [, exStyle = -1]]]] ) ok in 5 arg I got $TCS_BUTTONS
      But How can I use multiple args like this below
      Global $Tab1 = GUICtrlCreateTab(30, 30, 600, 420, [$TCS_BUTTONS, $TCS_MULTILINE], -1)  
    • Eggsplorer
      By Eggsplorer
      Hi,
      Ich hab ein Script für Windows Updates, dass nach dem OOBE aufgerufen werden soll. Run/RunOnce ist daher nicht möglich.
      Stattdessen möchte ich das Script in den Autostart schreiben lasse. Wenn die OOBE beendet wird und der Administrator angemeldet wird, soll das Update-Script einmalig aufgerufen werden und sich anschl. selbst löschen.
      Lang rede, kurzer Sinn:
      Wie kann ich folgendes Script in den Autostart schreiben?
      RunWait(@ComSpec & " /c " & "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File C:\UA\Scripts\win-updates.ps1 -MaxUpdatesPerCycle 100 -RestartRequired 1", "") Ich würde ungern eine BAT oder EXE reinkopieren, da ich es unsauber finde. Die müsste ja auch zusätzlich irgendwo liegen.
      Danke
      Eggsplorer
    • ur
      By ur
      I am running the tomcat batch file through autoit   and need to wait until the below line I get in console output.

      But when I am trying to read the console output using the ProcessEx UDF, I am getting only the partial output.
      So, can you please suggest how to handle this.
    • rinoatwisted
      By rinoatwisted
      Hello guys,
      im just started in programming and all..
      and i wanted to learn autoscript to.
      Was wondering if any can convert my  one-liner batch script to an autoit script -
      FOR /F %%i IN (names.txt) DO @copy system.act %%i.act
       
      So what this does is open and read the file "names.txt" incrementally, and copy a certain file named "system.act" and rename it to each name that is listed on "names.txt"
       
      So im trying this on autoit but no idea how to start file manipulation and do command -
       
      #include <File.au3>
      $file = "c:\names.txt"
      FileOpen($file, 0)
      For $i = 1 to _FileCountLines($file)
          $line = FileReadLine($file, $i)
       
      Can anyone help me or guide me on how to continue this to get the result that i want..:)?
      Thanks
    • fosil
      By fosil
      Hi everyone.

      I'm currently working a program that constantly prints out log files through "consolewrite" and the "#AutoIt3Wrapper_Change2CUI=y" wrapper.

      Part of this program requires me to run a batch script.

      My issue is the batch script launches from the same window as consolewrite. I need the batch file to be launched through a different window as currently this causes an issue with the logs (which need to be very precise) but also causes the batch file to produce some funny behavior...

      Does anyone know how I can force the file to run on a second DOS window?

      Thanks in advance!!!
       
      Edit: Im using the "run" command if that helps. I tried "shellexecute" but that seemed to not launch the batch scripts at all.