Jump to content

Confused about Scripts (I know it's been done a million times...)


Recommended Posts

Sorry, bad thread title, I meant confused about running a script as a service... mods please change if you gte a chance...

Ok so I've read every thread on here about how to make your program run as a service so it can run when the computer is locked etc. etc. I've seen this thread...

http://www.autoitscript.com/forum/index.ph...=80201&st=0

And I've read it, but I still have no idea what to do. I'm trying to follow the original directions. So if someone could walk me through it, please let me know.

So From what I understand, you copy and paste YOUR code into the "Service_Example.au3", where it says ";put what you want to run here" or whatever it says, compile it, run it in dos like so "Service_Example.exe /i". That all worked lovely for me, I got the service to come up, and I even started the service, but it doesn't do anything. My program moves the mouse and has lots of window calls etc(there is no way around it), so it has to be able to do all that stuff when the computer's locked, I read (somewhere, I just closed the window...) that I might need to include some code (somewhere) that allows the commands such as Win#### to work, but I have no idea where to put the code. I'm just really really confused about how to get this to work. If anybody could offer some help please let me know. Or even point me in the right direction, preferably to a step by step walkthrough...

Thanks in advance.

Edited by corrado33
Link to comment
Share on other sites

From the first post-

Programs that intend to be run as services will not have access to windows. So don't make any GUI's application with it. It's a security limitation, not a bug.

For example, functions like winkill and so on will not work.

I don't know what else to say other than a good-willed "RTFM"

Link to comment
Share on other sites

I did read the manual... however, if you go here

http://www.autoitscript.com/forum/index.php?showtopic=37289

and go to Q4, it says...

There is one caveat to setting up AutoIt as a service. If the service is not installed using the above code, it must have the "allow service to interact with the desktop" setting or else automation functions such as Control* or Win* functions will not function. To assure the service does indeed have this setting, use the following code:

So it is indeed possible. It may have been written later differently, however that page does not take into account this "security flaw," which frankly I couldn't care less about. Now all I really want to know is where to use the code below the quote above in the original web page, or the code earlier in Q4 on the original web page.

Thanks.

EDIT: I also found that I will have tweak my code a bit because of this...

Q21. Why my script doesn't work on locked station?

A21. On locked station any window will never be active (active is only dialog with text "Press Ctrl+Alt+Del")

In Windows locked state applications runs hidden (behind that visible dialog) and haven't focus and active status.

So generally don't use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc.

Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc.

This way you may have your script resistive against another active windows.

and it's possibe to run such script from scheduler on locked Windows station.

Edited by corrado33
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...