charlieb Posted April 16, 2018 Posted April 16, 2018 I have a CMD batch file that contains the following. putty -i key.ppk -R 12345:localhost:22 user@mycompany.com -pw testing123 GOAL: I'd like AutoIt script to run the same exact command above, but ASK for a number, and whatever number is inputted in the response to automatically REPLACE the 12345 number above with the entered number by the user and run the command. So when a user enters for example, 9876, then the scripts run the command below... putty -i key.ppk -R 9876:localhost:22 user@mycompany.com -pw testing123 Thank you for any assistance.
badcoder123 Posted April 16, 2018 Posted April 16, 2018 I have no idea on how to use any of that but I think this is what you're looking for? $input = InputBox("Key", "Enter the numeric key.") Run(@ComSpec & " /c " & 'putty -i key.ppk -R ' & $input & ':localhost:22 user@mycompany.com -pw testing123', "", @SW_SHOW) ;Change flag to @SW_HIDE charlieb 1
charlieb Posted April 16, 2018 Author Posted April 16, 2018 thx badcoder123 it works when I run the script, but I should of corrected my own CMD script. It is actually .\putty -i .\key.ppk -R 9876:localhost:22 user@mycompany.com -pw testing123 as you can see I have .\ prepending the command putty and key.ppk because I create an EXE that run my cmd script file with that content along with putty and the key.ppk file - all 3 files together in an EXE created by IEXPRESS. IEXPRESS just happends to extract those 3 files together to a temporary directory and executes the batch file and calls those other 2 files; hence .\ prepend. If I combine replace the cmd with your EXE based script, it doesn't execute. I did this and it didn't work. How do I ensure that when EXE that extracts this 3 files in temp dir that it calls them or refers to them. Thank you. $input = InputBox("Key", "Enter the numeric key.") Run(@ComSpec & " /c " & '.\putty -i .\key.ppk -R ' & $input & ':localhost:22 user@mycompany.com -pw testing123', "", @SW_SHOW) ;Change flag to @SW_HIDE
Earthshine Posted April 16, 2018 Posted April 16, 2018 (edited) you will probably want to change to that temp directory then beforehand, else provide full path names. i would find the temp and make it the working dir. https://www.autoitscript.com/autoit3/docs/functions/FileChangeDir.htm Edited April 16, 2018 by Earthshine My resources are limited. You must ask the right questions
charlieb Posted April 16, 2018 Author Posted April 16, 2018 Ok, it works now. Thanks all. Earthshine 1
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