TechnoMonster Posted December 15, 2016 Share Posted December 15, 2016 I'm using batch procedures to change a desired network adapter IP and gateway addresses by prompting the user for the Idx# of their wired LAN network adapter. Later, in a separate batch procedure, I'd like to be able to return "that" adapter to DHCP. This is what the fist batch proc looks like: @echo OFF :start cls echo. NetSh Interface IPv4 Show Interfaces echo. set input= echo Enter the "Idx #" above of the Wired Ethernet Network Adapter in your system: echo. set /p input="" if "%input%" == "" goto start netsh interface ipv4 set address name=%input% source=static addr=126.19.0.13 mask=255.0.0.0 gwmetric=1 exit Later, in a second batch procedure, I'd like to simply do something like: netsh interface ipv4 set address name=%input% source=dhcp but the variable %input% is no longer known. Suggestions? Thanks. Link to comment Share on other sites More sharing options...
SadBunny Posted December 15, 2016 Share Posted December 15, 2016 C:\tmp>type test1.bat @echo off set "timeOfTest1=%time%" echo "Test 1 time: %timeOfTest1%" C:\tmp>type test2.bat @echo off echo "Time of test 1 execution was: %timeOfTest1%" C:\tmp>test1.bat "Test 1 time: 0:34:13.80" C:\tmp>test2.bat "Time of test 1 execution was: 0:34:13.80" But what does that have to do with AutoIt? Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
TechnoMonster Posted December 16, 2016 Author Share Posted December 16, 2016 I"m calling these procedures from a single instance of an AutoIT program. I need the variable that the user specifies in an earlier procedure call to be used in a later procedure call. Link to comment Share on other sites More sharing options...
SadBunny Posted December 16, 2016 Share Posted December 16, 2016 You can use setx instead of set. You may have to run your script as admin though to be able to set Windows environment variables (add #RequireAdmin on top of your script). This works for me: test1.bat: @echo off setx timeOfTest1 "%time%" echo "Test 1 time: %timeOfTest1%" pause test2.bat: @echo off echo "Time of test 1 execution was: %timeOfTest1%" pause script: #RequireAdmin RunWait("c:\tmp\test2\test1.bat") RunWait("c:\tmp\test2\test2.bat") Good luck. Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now