Sign in to follow this  
Followers 0
banging

Script won't run when not logged in

8 posts in this topic

Hi,

I used the recorder to make this script and it works great except I'd like to be able to schedule it to run when I'm not logged in. Basically, it clicks through a gui for an application that remotely install some software. How would I go about making this work (or something similar) if I'm not logged in.

Opt("WinWaitDelay",100)

Opt("WinTitleMatchMode",4)

Opt("WinDetectHiddenText",1)

Opt("MouseCoordMode",0)

Run('C:\WINDOWS\system32\agentrollout.exe')

WinWait("PatchLink Agent Deployment","")

If Not WinActive("PatchLink Agent Deployment","") Then WinActivate("PatchLink Agent Deployment","")

WinWaitActive("PatchLink Agent Deployment","")

MouseMove(443,365)

MouseDown("left")

MouseUp("left")

Sleep(1000)

MouseDown("left")

MouseUp("left")

Sleep(1000)

MouseMove(185,127)

MouseDown("left")

MouseMove(31,124)

MouseUp("left")

Sleep(1000)

Send("jsmith{TAB}passwordhere")

MouseMove(35,311)

MouseDown("left")

MouseUp("left")

Sleep(1000)

MouseMove(437,362)

MouseDown("left")

MouseUp("left")

Sleep(1000)

MouseMove(64,153)

MouseDown("left")

MouseUp("left")

Sleep(1000)

Send("computername")

MouseMove(453,362)

MouseDown("left")

MouseUp("left")

Sleep(1000)

MouseMove(432,362)

MouseDown("left")

MouseUp("left")

Sleep(1000)

Share this post


Link to post
Share on other sites



Simple answer: You HAVE to be logged in to run a script.

Correct me if i'm mistaking: I've never seen anyone set AutoIt as a Windows Service, because the services start running when you aren't logged in yet. (I think)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I used the recorder to make this script and it works great except I'd like to be able to schedule it to run when I'm not logged in.

I do remote automated cleanup of 400+ computers using AutoIT scripts. I run one locally to collect the parameters for which functions to run and create a variable string with nothing but 1's and 4's in it (checked or not checked).

I then send the second app to the target machine using PSEXEC from Sysinternals and pump in the variable as the command line parameter. The second program is "gui-less", but takes its commands from the command line input and runs only those cleanup apps that I've selected in the first script.

You need to re-write your script without mouse moves, and replace them with winwait/ctrlclick/run/runwait commands instead. With the proper permissions your program will run on the target machine whether or not any user is logged in. In fact, I've found that my clean up app runs even if a user logs in and then logs off again... Of course, I have admin priviledges to do all this...

Edited by jefhal

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Ok, I thought I may have to re-write it the other commands. I had some trouble so I tried the recorder and it worked. I'm testing it tonight. I have an RDP /console session open from my desktop at work to a windows 2003 server where the script is and the app I'm controlling with the script. I can't pass in any variables to this app and it's proprietary, no scheduling. I had to disable the password authentication/screensaver which prevented the script from running and it seems to run as long as I stay logged into the server from my desktop - even a disconnect session won't allow the script to run - it runs after authenticating - which would probably get me fired if this happens at the wrong time. :D

Share this post


Link to post
Share on other sites

it runs after authenticating - which would probably get me fired if this happens at the wrong time. :wacko:

I hear you. I fired off my script a few times when teachers were still logged in. Scared the heck out of them. Now I do a check first to see if a. the machine is on, b. if anyone is logged on (I use Sysinternals psloggedon.exe for that part)... :D

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Autoit needs console for executing the script, I had same problem. I changed the remote host to autologin mode then through psexec i am able to execute the scripts in windows 2003 and windows xp machine.

http://support.microsoft.com/kb/315231 - Details to setup autologin.

Share this post


Link to post
Share on other sites

Group policy can run AutoIt scripts. Adding the procedure to a Startup or Shutdown script will allow your script to run when no one is logged on.

Using active window functions may not work at this period. Use WinWait and Control*() functions that do not require active windows.

Share this post


Link to post
Share on other sites

Now I do a check first to see if a. the machine is on, b. if anyone is logged on (I use Sysinternals psloggedon.exe for that part)... :D

Just checking for explorer.exe running will tell you if anyone's logged on.

You could then run it with a pop-up saying something like "Important System Mainenance needs to run, click OK to continue" or something like that.


"I'm not even supposed to be here today!" -Dante (Hicks)

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  
Followers 0