Jump to content

Sending Commands to hidden CMD window?


Recommended Posts

Hi everybody,

i'm pretty new to autoit (just discovered it this Monday) and i have banging my head on to following problem.

Everything i talk about is running on a remote Windows XP machine, which is only accessed using Remote Desktop.

I got a cmd window open, that is running a server, and want to send some keystrokes to it.

Right now i do this using the following code.

If WinExists ('windowname') Then
WinActivate ('windowname')
Send ('Hello i am some text {ENTER}')
EndIf

Which works perfectly fine, at least as long as i am logged in with Remote Desktop.

When i close Remote Desktop, the script is no longer working.

I think it is because the window can't be active when there is no RDP connection (i don't log off, i just close it so everything keeps running)

In theory, it needs be threated like a hidden window.

But ControlSend is not working, as i found out today,, it is doesn't work for CMD Windows.

Is there any way to still do what i want? Except leaving the RDP connection open.

Otherwise i would have do run that command for the server by hand every 6 hours :oops:

Link to comment
Share on other sites

Why not running an Autoit script as a service on that machnine. Then it could handle everything on its own (without dealing with windows)

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • Moderators

Hi, Otacon, welcome to the forum. Depending on what command you're trying to pass to the command window, you could also simply use AutoIt's Run or ShellExecute functions, and then use PSExec (found here) to run it from your remote machine.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Why not running an Autoit script as a service on that machnine. Then it could handle everything on its own (without dealing with windows)

I have to send the command to the existing CMD window which runs a server.

I don't want the server to run as a service, as its window is the only way to send commands to it.

Hi, Otacon, welcome to the forum. Depending on what command you're trying to pass to the command window, you could also simply use AutoIt's Run or ShellExecute functions, and then use PSExec (found here) to run it from your remote machine.

Its an already existing window to which i need to pass commands too for a Server. Things like "Stop {Enter}" or "Save {Enter}"

It won't work if i just run a shell command, otherwise it would be quite easy :oops:

Another thought of me.

If i let AutoIt start the server inside a CMD window i opened with AutoIt, would it that change things to send commands to it?

As i don't care if the server is started by a *.bat or AutoIt, because that shouldn't matter for the Server at all.

Edited by Otacon
Link to comment
Share on other sites

  • 1 month later...
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...