Why Autoit script doesn't run over SSH (W10)? - windows

a simple command on AutoIT:
ControlClick("Sighthound Video","","[CLASS:wxWindowNR; INSTANCE:46]","Primary")
ControlClick("Sighthound Video","","[CLASS:wxWindowNR; INSTANCE:49]","Primary")
to click a button in an application.
I create a script called "Toggle.au3".
If I click double click, it works.
If I launch it from the command line, it works.
If I launch from a remote computer with Putty (through SSH) it doesn't works; no error appears but doesn't perform the tasks.
Why? I have also tried to compile in a exe file, but nothing changes.
Windows 10
Bitvise SSH Server
AutoIT 3.3.14.2
THX.

It is because you don't have rights from a remote computer.
If the au3.exe gets the remote's privilege then it is definitely not going to interact.
Edit: However ALL autoit commands are windows based commands, which means C++ commands. If you can call those commands through putty or CMD then it might work

Related

How to submit Plink "Access granted. Press Return to begin session" prompt automatically

I'm writing a simple Windows batch script to allow me to execute some Linux command on my remote server with the help of plink.exe.
call set argument1=plink -pw mypwsswd username#172.19.48.111 cd ~/project; make clean; make -j8
call plink %%argument1%%
In a word, it will rebuild my C++ project on the remote server.
When I double click the batch, it works except that I have to type an Enter each time.
Access granted. Press Return to begin session
As you see, after I getting this windows, I have to type an Enter to continue.
Is there some way to avoid this? For example, typing an enter automatically?
Since PuTTY 0.71 you get that prompt for security purposes, when you login in an interactive mode. See PuTTY vulnerability vuln-auth-prompt-spoofing.
To use a batch mode, use -batch switch. That way you not only get rid of that prompt. It will also make sure the command does not hang on various other prompts that may occur, when something changes. Instead the command fails straight away.
If you want to keep the interactive mode, but avoid this specific prompt only, use -no-antispoof switch.

PhpStorm - run terminal (cmd) as administrator

On Windows it's easy to run cmd application as administrator:
Right click on cmd icon >> run as administrator`
But I would like to use PhpStorm terminal tool as administrator since I constantly have to execute queries that require administrator role.
When I open:
File >> Settings >> Tools >> Terminal
I can see that it is directly connected to cmd.exe and there are options to be filled:
And I see no checkbox with choice to run it as administrator.
QUESTIONS
Is it even possible?
If yes how do I do it?
Using settings or other way?
There are no options in the IDE for that at the moment: to run the shell (cmd.exe, powershell.exe etc.) with higher rights.
https://youtrack.jetbrains.com/issue/IDEA-121335 -- watch this ticket (star/vote/comment) to get notified on any progress. Maybe someone will post some possible workarounds there...
Your only option for now (that I'm aware of) is running IDE itself as Administrator -- Process Hacker tool confirms that both the IDE and cmd.exe will be run with elevated rights.
P.S.
For one time execution (or if you need to run IDE as normal user) -- have a look at this question and offered solutions: How to open an elevated cmd using command line for Windows?

How do I tell a windows batch script to execute the next line without waiting for the previous line to finish executing?

I'm setting up a .cmd script to be run on startup for a pseudo-server (It's actually a laptop, but that's irrelevant) to automatically launch pageant, load an SSH key, connect to an SSH server using Putty (Pageant would automatically authenticate with the key), then launch mIRC which in turn has a series of scripts setup to operate as an IRC bot and automatically connect to networks using putty as an SSH tunnel.
With that in mind, I have the below code in a startup.cmd file:
"C:\Program Files (x86)\PuTTY\pageant.exe" c:\Path\To\Private\Key.ppk
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh user#host
"C:\Program Files (x86)\mIRC\mirc.exe"
EXIT
When I test run this file, the command prompt runs the first line, launches pageant, and then sits there and does nothing until I close pageant completely. I believe I have an idea on what the issue here is, but I can't find any information on how to resolve this in a batch file.
I do know on linux systems, if I were running a bash script to do something similar, I would want to have a & symbol at the end of each line to tell it to run the next command without waiting for the previous command to finish executing. I did try that in the batch script in the off chance that would work (It didn't).
For those who may ask, this is on Windows 8.1 64 bit. The user running this script is not an administrator.
I can't comment to expand on Squashman's suggestion, so let me answer here.
In your case, if you only want to have Pageant running in the background, without interacting with it, I think it's best to run:
START "" /B <your command>
The /B parameter will spawn the process without launching a new window for it, which seems like something you'd like to avoid (anyway, it's probably closest to the behaviour you can obtain in Linux with &).
Please note that if you close the window from which you spawned this process, it will terminate as well.

Opening Cygwin with Windows bat file and running script file

I require a tunnel between my windows machine to a UNIX server and wish to automate the process so that on startup the tunnel will be generated for me.
I installed Cygwin with ssh and autossh to connect to the remote server, built up the connection manually, and have confirmed that the connection works. The process involves 3 commands, which isn't a lot but something that would be great to have automated.
After creating a .sh script file, which includes my autossh connection commands, and saving it using Notepad ++ as a UNIX document (to avoid any potential conflicts regarding the file ending), I can navigate to this script in Cygwin and call bash script.sh. After which the connection is made and I can work on my server.
My problem comes when creating my bat file:
start /d "C:\cygwin\bin\" mintty.exe "C:\Users\user\Documents\Dev\" script.sh
The first part up to and including the .exe file works to open the Cygwin window, but I have been unsuccessful in feeding the script into it. I even tried including a --bash command before referencing the script file as follows, but I received an error that the command is unknown:
start /d "C:\cygwin\bin\" mintty.exe --bash "C:\Users\andrew\Documents\Development\" tunnel.sh
Does anyone know if and how it is possible to open a Cygwin window and call a script file within this window? This is my first time creating a bat file, so I hope this is perhaps a newbie problem that no one even bothers to post a solution online for...
you don't need start.
assuming your Cygwin is in C:\cygwin
you need just:
chdir c:\cygwin\bin
mintty /usr/bin/bash -l -c /cygdrive/c/Users/user/Documents/Dev/script.sh

Open Excel on Jenkins CI

I am working on Windows 7 (logged in as session no.1), my Jenkins CI is running as windows service in session 0.
My problem is.. I want to open an Excel file through Jenkins CI in session 0, but want to display its GUI on session 1.
I know that session 0 is isolated in Windows 7, but is it possible to run a process in session 0 and then output in another session? please help.
Edit:
Took a little trial and error, but this is what finally worked for me (Windows 7 64-bit).
Download PsTools from Microsoft site
We only need psexec.exe, but you can extract everything. Extract to some location accessible by Jenkins, preferably without spaces in the path.
Open elevated command prompt: type cmd into Start's quicksearch, right click cmd.exe, select Run as Administrator.
Type C:\path\to\psexec.exe -accepteula and press enter.
Type C:\path\to\psexec.exe -i 1 cmd and press enter. (If you see a command prompt appear, all is good, close it now)
In Job configuration, configure Execute Windows Batch command step
Write the following:
C:\path\to\psexec.exe -accepteula && C:\path\to\psexec.exe -i 1 cmd /c start C:\PROGRA~2\MICROSO~1\path\to\excel.exe
Where:
C:\path\to is your full path to psexec.exe, unless it is in your %path%
-i 1 is the session ID that you want to launch in.
C:\PROGRA~2\MICROSO~1\path\to is your full path to excel.exe without spaces. Since most Office installations are going to be under paths with spaces, like "Program Files (x86), you have to figure out the short path, or place it somewhere without spaces.
Having excel.exe under %path% and working from regular command line was not enough.
A little explanation for those that care:
psexec needs to install a services first. For that, it needs to be run from elevated command prompt for the first time. This is a one-time installation step.
To make psexec work, you need to accept the EULA prompt. This is done per session/user. So even if you run psexec -accepteula in your command prompt, it doesn't help when Jenkins service (running as Local System in session 0) tries to use it. Therefore, you have to place that into the Jenkins job, along with the command. Technically, it only needs to be there once, and can be removed afterwards, but it definitely doesn't hurt to keep it there.
I've used cmd /k and running this command from my local cmd prompt to debug. This is what made me realize I couldn't find a way to escape the spaces (tried various quoting), so had to resort to short file names. Note that short file names are not required, this is just to escape spaces.
no its not-
plus any UI interactions requires you to run Jenkins as Java web start rather than a service or you can not interact with UI elements.

Resources