Run sql remotely via vb script

I am trying to connect to putty, login into a remote linux server and execute a sql command file.
I can open the connection fine, but no keys are sent when I'm not logged in (works fine if I am logged in)
However, send keys is not working when I am not logged in. I was trying to do this through vbscript:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files (x86)\PuTTY\putty.exe"" user@server -pw password", 9
WshShell.AppActivate("Window Title")
WScript.Sleep 20000
WshShell.SendKeys "dbaccess db@dbserver commandfilepath"
WScript.Sleep 20000
WshShell.SendKeys "{ENTER}"
WScript.Sleep 20000
WshShell.SendKeys "exit"
WshShell.SendKeys ("{Enter}")
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Why wouldn't you just run a remote bash script at the same time as you use ssh to connect to that NIX box?

ssh yourusername@server1 './'

I think the script would need to be in that user's profile and you may have to play around with the syntax, but this seems a lot simpler.

Is dbaccess a local program that you are trying to use to connect to the remote dbserver?  If so what server? What exactly are you trying to accomplish?  Doing sendkeys seems like an around the world type way to do something like this.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.