Sign in to follow this  
Followers 0
Guest nicnic

Script to run as a service.

21 posts in this topic

Hi

We've written a script which detects when a Stack error reports screen pops up,

captures it as a bmp and kills the window.

Issue is when we logout Auto it stops. We would like out Autoit scripts to run on a NT server whilst noone is logged in. Best way I think we can do this is compile and

use as a Windows NT service.

It this possible??

Thanks

Nic

Share this post


Link to post
Share on other sites



you can use the srvany utility from Microsoft (free windows 2003 support tools):

--------------------------------------------------------

Applications as Services Utility (SrvAny) is a tool that enables 32-bit or 16-bit applications to run as services. Although SrvAny only runs on the Windows Server 2003 operating system, it can work with 32-bit applications written for Windows Server 2003, Windows 2000, or Windows NT

-----------------------------------------

Bye

Ros

Share this post


Link to post
Share on other sites

I know it's technically not the same thing as a service, but I've used the windows "Scheduled Tasks" control panel to launch programs on system start. It's how I launch a few of my own AutoIt scripts on a dedicated sever that I administrate. Sometimes the server needs to reboot (at least every 72 hours to keep it running clean on 256 MB of RAM) so one of the scripts just reboots it after that long.

I don't know if this will work for you, but it might be worth looking into.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

or even start the script using

PSEXEC -s -d start "" c:\script_name.au3

This can be! It needs testing...

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I tested doing:

psexec -s -d cmd

Logging off and relogin and the CMD process was still there!

So it should work! Tomorrow I'll make a more serious test and tell! :(

The problem is that it starts from CL so it needs that a user log in for the first time...

Autologin, start and logoff? :ph34r:

Edited by ezzetabi

Share this post


Link to post
Share on other sites

Why not use a scheduled task to start with? It should so the same thing, but no need to log on for the first time.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Yeah. Thats a very good idea.

Share this post


Link to post
Share on other sites

Guys thanks for the help.

Downloaded the ps utils but I'm unable to login to run these.

I'm on a different domain to the servers I wish to control

and I'm unsure of the correct form of the statement .i.e

both of these statements give Access denied when the password is correct.

psinfo \\domainname\servername -u \\login name

psinfo \\servername -u \\domain\login name

Could anyone help or give me an address of a forum for help concerning ptools.?

-

Tried looking at Scheduled Tasks but I'm only able to find winat on the Windows NT4 servers. Any ideas where to look on an NT box?

Cheers

Nic

Share this post


Link to post
Share on other sites

Tried looking at Scheduled Tasks but I'm only able to find winat on the Windows NT4 servers. Any ideas where to look on an NT box?

I don't know about NT, but on 2k, XP, and I believe 9x you can find it in the Control Panel --> Scheduled Tasks folder. Double click the "add task" and pick start on "computer boot."

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

Thats ok I've found Scheduled tasks but still interested in any answers to the ptools question?

Thanks

Nic

Share this post


Link to post
Share on other sites

Guys

I've tried the Scheduler Task and it refuses to run our compiled Autoit utility at startup (no errors, Scheduler states running but nothing in taskmanager or the lower right taskbar icon).

Scheduling a time to start very occasionly works.

Any idea why this is the case with compiled Autoit utilities?

SRVANY will successfully place the utility in the NT service list but trying to start the service gives an Error 2140: An internal Windows NT error occured.

Can you recommend anything we should change in our source?

If it helps we can paste the source?

Cheers again

Nic

Share this post


Link to post
Share on other sites

Guys

I've tried the Scheduler Task and it refuses to run our compiled Autoit utility at startup (no errors, Scheduler states running but nothing in taskmanager or the lower right taskbar icon).

Scheduling a time to start very occasionly works.

Any idea why this is the case with compiled Autoit utilities?

SRVANY will successfully place the utility in the NT service list but trying to start the service gives an Error 2140: An internal Windows NT error occured.

Can you recommend anything we should change in our source?

If it helps we can paste the source?

Cheers again

Nic

If you post the source i can try it in my PC with srvany.

bye

Ros

Share this post


Link to post
Share on other sites

"Stack error reports screen pops up"

does not mean that te scrip is needed only the someone is logged in?

Share this post


Link to post
Share on other sites

Try this:

http://www.pirmasoft.de/runassvc.php

RunAsSvc runs normal programs as services so that they are running in the background, even when no user is logged on.

RunAsSvc has been tested on Windows 2000 and Windows XP, but it should also run on Windows NT 4.0.

Share this post


Link to post
Share on other sites

Guys

I've tried the Scheduler Task and it refuses to run our compiled Autoit utility at startup (no errors, Scheduler states running but nothing in taskmanager or the lower right taskbar icon).

Scheduling a time to start very occasionly works.

Any idea why this is the case with compiled Autoit utilities?

SRVANY will successfully place the utility in the NT service list but trying to start the service gives an Error 2140: An internal Windows NT error occured.

Can you recommend anything we should change in our source?

If it helps we can paste the source?

Cheers again

Nic

Duh, it won't appear in the taskbar because it's running on boot, not as a particular user. That's what I so carefully pointed out when I discussed the difference between using the startup folder and a service or schedule on boot.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I've had plenty of sucess using PSEXEC, the AT command, and audit. The AT commands from the cmd line will show up in task scheduler. Play around with them a bit and I'm sure you will get them to work on your machine and others.

But I'm curious on the sucess that people have for manipulating the GUI/Windows when the user is logged OFF or the screen/computer is locked. For a normal autoit script only the console, cmd line, or reg commands will usually work, but the GUI/Windows commands will not. Maybe some of the helpers can speak more to that situation.

What are different tricks, programs, and autoit commands that people use to have GUI/Window manipulation autoit programs run when the user is logged off or the computer is locked???

Perhaps making a list will be very helpful for many others.

Edited by autoitNOW

An ADVOCATE for AutoIT

Share this post


Link to post
Share on other sites

I'm about to play around some with a script that starts on boot with GUI/ window/ messgae box commands to see how it works.

In the meantime, here's an interesting solution: create the "main" script to start on boot, and have a "subscript" start on each user's login (just add it to the startup folder, or manually add it in the registry if you desire and know how.) Then, when you want to create a message box, or other graphical manipulation/ input the main script can just communicate that to the proper subscript via use of the AutoIt window, or communication files as the case warrents.


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

If you have an autoit script as a service, make sure you go to services.msc, open the properties for the service, select the log on tab and check "allow service to interact with the desktop".


Who else would I be?

Share this post


Link to post
Share on other sites

this-is-me has hit it. In order for Window-based commands to work, the script has to be running in the same desktop as those windows. The active desktop (which you see on your monitor) may not be the desktop a service sees. The option this-is-me mentioned does allow a service running on a SYSTEM account to see the current desktop and interact with it.

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