I can't duplicate the Putty window you're seeing (I only get PuTTY Configuration).
Some suggestions:
- Replace the ENTER keys with TAB (except the last one). This will prevent dismissing the window prematurely.
- Combine "sm_reloadadmins" into a single operation. Less instructions, less problems.
- Lower the sleep times. I've always had better results with quick fire keystrokes and cursor movement. Too much can happen in 20 seconds.
- Test the VBScript one control at a time and see how it progresses. For example, first test the script so "SUPERSECRETPASSWORD" gets entered correctly and the cursor moves to the next field. Add the next control to the VBS and test again.
Sendkeys simply sends out keystrokes. Whether any application is there to catch them makes no difference.
Any chance you can use command line parameters instead of the GUI?
1. Can't replace enter keys with TAB or it won't execute the text. I tried doing it, and it typed out all the commands fine...into the user input field.
2. Done, now it sends "oadadmins".
3. See above.
4. The only part that experiences an issue is the final "sm_reloadadmins" part.
I'm not sure how I would use command line parameters for this, as once I run "screen -x" I'm no longer sending commands to putty, I'm sending them to the game server. I did use parameters for the username/password though.
I tried to do the AppActivate trick as well, and it didn't change anything from above.
Semi-functional code:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files (x86)\PuTTY\putty.exe"" root@IPADDRESS -pw SUPERSECRETPASSWORD", 9
WScript.Sleep 3000
WshShell.SendKeys "screen -x"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 1000
WshShell.AppActivate("[screen 0: srcds_run]")
WshShell.SendKeys "sm_reloadadmins"
WScript.Sleep 2000
WshShell.SendKeys "{ENTER}"
WScript.Sleep 2000
EDIT: Now it manages to write "reloadadmins"...