Jump to content

OpenSSH %PATH% Environment Variable issue

Recommended Posts

Hello all, new to the forum and I've only used AutoIT for some very basic command automation.

I'm writing a password reset script for a small help desk. The script will ssh in a hidden cmd process, execute the password reset process in the background and confirm completion. 

The issue I'm having is when I run the script with the ssh.exe in the local or working path it runs fine but if I try to execute it without it fails

"'ssh' is not recognized as an internal or external command, operable program or batch file."

Right now i am calling it with

Run("C:\WINDOWS\SYSTEM32\cmd.exe" ,"", @SW_SHOW) @SW_SHOW is just for testing

$hCmd = WinGetHandle("C:\WINDOWS\SYSTEM32\cmd.exe")

ControlSend($hCmd, "", "", 'ssh -o "StrictHostKeyChecking no" user@server' & @CR)

I've also tried 

RunWait(@ComSpec & " /k " &'ssh -o "StrictHostKeyChecking no" user@server' ,"", @SW_SHOW)

I can execute the ssh commend from the start, run or cmd line in a standard window I open myself, just cannot execute the command from the cmd process launched by AutoIT.

ssh falls under the %PATH% listed C:\Windows\System32\OpenSSH in environmental variables, the cmd processed opened shows it is running as the local user logged in. I'm just not sure the difference on access to the exe when launched by the script.

Any pointers on how to call the process that sits in an common environmental variable would be much appreciated. Thanks

Link to post
Share on other sites

On 64-bit systems you need to run 64-bit version of cmd, example:

;~ The following script can be compiled as 32-bit

#include <WinAPIFiles.au3>

RunWait(@ComSpec & " /k " &'ssh -o "StrictHostKeyChecking no" user@server' ,"", @SW_SHOW)

Or just compile the script as 64-bit

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
RunWait(@ComSpec & " /k " &'ssh -o "StrictHostKeyChecking no" user@server' ,"", @SW_SHOW)


Edited by Subz
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...