I am doing a manual process that is done each day within Putty and wanted to automate it. There is no need for a person to do this because all of the keyboard inputs do not change each day. I'm trying to free up time to increase productivity, not to mention it is mind-numbing to continually do this every day. The process requires someone to open Putty (this would use plink of course), login (storing the password and username in plain text is fine, steps for generating a key are not necessary), enter the same keyboard presses, output the file manually, and then save it to a network drive folder. So this is a completely unnecessary process to have someone doing it manually and I am seeking a way to complete this automation.
Currently, this is being used in a Windows 10 environment and from what I have read, Putty (plink) is the best route to go. I can utilize other SSH programs if there is a better method as well, but I think this may be the better route from the research I've done. I haven't scripted much at all and I'm trying to learn a bit as I go with this. I need to automate logging into PLINK (done) and then multiple keyboard entries (kind of done) for each screen within the server I'm accessing. Essentially, each screen needs to enter predetermined keyboard keys, such as "ENTER", some numbers 1-10 depending on the screen and then when it is complete, I need to print the results to a file, which preferably would be a xlsx, but csv or text would suffice as well.
I have added the code that I was able to create so far below. I am stuck at this point because PLINK does not remain visible so it's tough to analyze the issue and the cursor keeps jumping to any active window when running it.
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "C:\PuTTY\plink.exe 123.server.com -l username -pw password -t{ENTER}"
WScript.Sleep 3000
WshShell.AppActivate "plink.exe"
WScript.Sleep 2000
WshShell.AppActivate "plink.exe"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 6000
WshShell.AppActivate "plink.exe"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 6000
WshShell.AppActivate "plink.exe"
WshShell.SendKeys "command123{ENTER}"
Update
I attempted to use the suggested code and it does work in terms of automating the login and bringing up the application within the server, but it is not accepting any of the inputs I attempt to code. Every time an input is used the following message below is displayed. Please note, my command I'm passing is 100% correct, it just seems to not even consider it. The script does actually input the text into the proper field, but it just errors it out.
Enter program name (or abbreviation): I don't recognize
that program name. Press <return> for a list of programs."
(I have updated code per suggestions).
(
echo WEST COAST
timeout /t 5 > nul
echo 09
timeout /t 5 > nul
echo third_screen_keys
) | C:\PuTTY\plink.exe 123.server.com:PORT# -l username -pw password -t