Jump to content
Sign in to follow this  
LoWang

Scripting without windows - is it possible?

Recommended Posts

We need to do some automated things like installing programs. But we need to do it remotely on other computers and without having to log in as normal user! Actually we can run programs on command line, but there is a problem with interactive programs and installers, because they need to display windows. I think it will not be possible to use AutoIt script to control installers with next, next... buttons if I am remotely logged in so there is no desktop or taskbar displayed on the remote computer. Am I true or there is some possibility to do installs without really going to that computer and loging in to show desktop where windows can appear?

Share this post


Link to post
Share on other sites

Sure, it's possible to do what you are asking. All you would need to do is create the script to start the install and click through any next or folder destination buttons. Then start the script on the remote computer. That can be done very easily in a number of different ways. Either set it up to run upon next reboot, or you could use a 3rd party software from another very cool site. www.sysinternals.com

They have a set of utils called PSTOOLS. Inside that suite, you will find an exe called psexec. This program allows for running apps, scripts, etc... on remote systems. Use the help to figure out how to use it. Very easy to learn.

So, all you'd have is copy the installer and installer script that you create to the remote system, then run psexec to initiate the script on the remote computer and if the script is setup correctly, then it will start the installer, finish the install and close out, as well as restart the system if a system restart is necessary after the install. PSTOOLS also has a util to do the restart if you need it. psshutdown.

Let me know if this helps.


jason7237

Share this post


Link to post
Share on other sites

So, all you'd have is copy the installer and installer script that ....

Pack all needed files into one compiled AutoIT-EXE and use psexec with the "-c" option, the copy of the exe will be done by psexec.

Share this post


Link to post
Share on other sites

:( I appreciate your assurements, but you probably didn't understand me :(

I know (and tried) that running script on remote computer, where noone is logged in is possible, BUT that script probably cannot do anything with windows. Now I wanted to do some example script which runs a BAT file "notepad.exe c:\readme.txt", then get text from the notepad window and saves it to another file. It works on local but fails on Winwaitactive on remote machine, because it simply cannot display any window I think. Even the -i parameter in psexec doesn't work.

So do you still think there is any way to run scripts on machines where is nobody logged in? I need to remotely gain some information, which I don't know where to see but in some window. If it would be possible to get text from window or control while there is no possibility to display it on the local display, tell me...

Edited by LoWang

Share this post


Link to post
Share on other sites

Now I wanted to do some example script which runs a BAT file "notepad.exe c:\readme.txt", then get text from the notepad window and saves it to another file.

<{POST_SNAPBACK}>

What is the point? If you want to retrieve the information in the file you can just use FileRead() and FileReadLine(), but seeing as your just opening up a file with notepad, retrieving whats in it and then saving it to another file, you can just use

FileCopy () changing the destination.

Edited by Burrup

qq

Share this post


Link to post
Share on other sites

What is the point? If you want to retrieve the information in the file you can just use FileRead() and FileReadLine(), but seeing as your just opening up a file with notepad, retrieving whats in it and then saving it to another file, you can just use

FileCopy () changing the destination.

<{POST_SNAPBACK}>

:(

I know I could get text from that file directly by reading it, but by this test script I only wanted to test if the windows manipulating is posible on remote computer where nobody is logged on.

The point is, that I do some script, which NEEDS a window to be opened and then gain information from it. It cannot get those information from anywhere else (or I am quite sure it's not possible), so it's needed to let that program run, it then displays results in a window and then I can get them for example by controlgettext (the results are in Internet Explorer control in HTML format). So this I am afraid, is not possible when running on computer remotely through psexec. :(

Share this post


Link to post
Share on other sites

I don't think you can run a script, or a program for that matter, while someone isn't logged on. Well I tried this any way at my school and it didnt work.


qq

Share this post


Link to post
Share on other sites
Guest caleishm

You can definitely run programs and scripts when not logged in at the console. As soon as you log in, all the applications you have opened by scheduling or from remote (eg. via ssh login with 'interact with desktop' enabled) are open and waiting for you.

But it seems that autoit cannot 'see' those windows when it's running, so if you have actions to interact with them, they wont work until you login (either on the console or via remote desktop connection).

I too would like a solution to this. My situation is that I'm trying to set up a build server, driving a silly development tool we have that only has a GUI interface. Clearly I don't really want to leave the build server logged in all the time - and worse, as soon as you connect via remote desktop, it logs out the console and then when you close remote desktop nobody is logged in anymore (and the builds stop working).

Any suggestions from people who know how these things work?

Share this post


Link to post
Share on other sites
Guest caleishm

Another way of looking at it.....

I have a autoit script that fires up some gui apps and interacts with them. It works quite happily normally. I can even run it happily when logged into the box over Remote Desktop.

But if I log out of remote desktop while the script is running, then autoit stalls and stops interacting with windows. This is dispite windows insisting that:

Any programs running on the remote Windows computer will continue to run while you are disconnected.  You can reconnect this session later by logging in again.

(I guess that technically autoit is still running - it just can't 'see' the other windows anymore). As soon as a log back in again, everything resumes.

The question is - can autoit be made to 'see' windows even when your disconnected?

Share this post


Link to post
Share on other sites

There was a small exploit someone pointed out to me a while ago that replacing the active screensaver with cmd.exe will allow a command prompt when no one is logged in, running as SYSTEM.

Could you replace the screensaver with an autoit script, launch explorer.exe (which can be done), and then do what you need, just do a BlockInput(1)...? Maybe a Reg Key to tell if the installs are already done, so as to replace the script with the original screensaver (might need a batch file to do it, start it, do a goto loop, and just move the file over the script and what not)


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

The question is - can autoit be made to 'see' windows even when your disconnected?

<{POST_SNAPBACK}>

Hey! It's my first post! I've been using AutoIt to solve problems for about 2 months now.

A few days ago I thought I could use Remote Desktop to solve my problems. I created a user just to process some email messages.

What I found was that during processing, if I minimized the Remote Desktop session AutoIt would pause execution. When I maximized the Remote Desktop session AutoIt would continue right where it left off. There was an occasional hiccup, as it jumped one line, or so, ahead in the script, but for the most part, it continued.

This has the same effect if I disconnect from the session. Reconnecting will continue execution. As you all have found.

I found my way to this forum where I found you all with the same issues.

I do not want to take up a workstation, or server console, to process tasks. I'd like to use the Terminal Server and have Remote Desktop sessions. Each session is a user named for what it does. And of course the only time that process would halt is if the server was rebooted.

I would love a solution to this interactivity with the processes running in the Remote Desktop Session!!

Regards,

Doug

Share this post


Link to post
Share on other sites

We need to do some automated things like installing programs. But we need to do it remotely on other computers and without having to log in as normal user! Actually we can run programs on command line, but there is a problem with interactive programs and installers, because they need to display windows. I think it will not be possible to use AutoIt script to control installers with next, next... buttons if I am remotely logged in so there is no desktop or taskbar displayed on the remote computer. Am I true or there is some possibility to do installs without really going to that computer and loging in to show desktop where windows can appear?

LoWang,

Which programs are you trying to run/install. If you are Domain Admin and Local Admin, you can use PSEXEC to send a unattended install script. I use that alot in out environment and it works wonders. there are a few caveats to that, mostly that PSEXEC sessions are not interactive, so you have to throw all possible options in that command line. you can even create unattended install Scripts, which will be copied over to the remote host and run as SYSTEM. PSEXEC is basically a smart NETCAT + AT Hack thats very convenient.

Most new applications use MSI style installs (sometimes compiled as EXEs). you can use command line options and Transforms with MSIs for silent/unattended installs. we have created a alternate install script for our Office 2003 deployment without depending on SMS.

here's a resource that I find useful:

http://unattended.sourceforge.net/installers.php

All you really need to do is identify what kind of installer was used to package the software then it's easy sailing.

alternatively, you can use Active directory to run apps/installs at startup (not to be confused with logon), or even at shutdown/logoff.

I use GPOs to set logoff and shutdown scripts that do things that users dont need to sit through (Patch management, AV updates, bla bla bla).


---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites

Dear LoWang,

I am going through the same problem. Any solution you get at this point? Thanks.

Wen

:)

I know I could get text from that file directly by reading it, but by this test script I only wanted to test if the windows manipulating is posible on remote computer where nobody is logged on.

The point is, that I do some script, which NEEDS a window to be opened and then gain information from it. It cannot get those information from anywhere else (or I am quite sure it's not possible), so it's needed to let that program run, it then displays results in a window and then I can get them for example by controlgettext (the results are in Internet Explorer control in HTML format). So this I am afraid, is not possible when running on computer remotely through psexec. :)

Share this post


Link to post
Share on other sites

Dear LoWang,

I am going through the same problem. Any solution you get at this point? Thanks.

Wen

I find that if you use only commands that does not require an active window to interact with, then it is possible to run GUIs without logging on.

Try the commands

ControlClick

ControlSend

WinWait

WinMenuSelectItem

etc...

They could come in pretty handy.

Share this post


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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...