Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

_Service_UDF v4 : Build your own service with autoit code

Service 1053 1061 compile

  • Please log in to reply
331 replies to this topic

#61 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 19 September 2008 - 03:30 PM

Right.
I've not added registry functions.
So the service is not well registered when you create it.
I've discovered it when i was trying to use the sc command : service doesn't exist.

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

 

Projects :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here







#62 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 22 September 2008 - 03:06 PM

at the creation, you have to enable in the type parameters , this flag : $SERVICE_INTERACTIVE_PROCESS
or if already created, edit the properties of your service and make it interactive.

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

 

Projects :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#63 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 22 September 2008 - 03:41 PM

if you try to make it interactive while you're not logged on, it's not possible.
for me the interaction is possible so i wonder what do you want to do exactly :)

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

 

Projects :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#64 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 22 September 2008 - 04:18 PM

plz look the first post. Stop trying to launch a service from the program itself.

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

 

Projects :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#65 CaryLewis

CaryLewis

    Seeker

  • Active Members
  • 5 posts

Posted 24 September 2008 - 12:36 AM

I have been trying to get an AutoIt script to run as a service.

I need to be able to monitor a Logon Window, and when the user has logged on, detect subsequent windows, and interact with them from the script, by clicking on buttons, sending keystrokes, launching new programs, etc.

But I can not get this work at all.

When I run a script as service, it can not see all of the desktop windows.

If I uncheck the "Allow Service to Interact with Desktop" the script can see more windows than if it is checked.

I have tried: the service.au3 code, srvany, and even Cygwin's cygrunsrv service wrapper.

Clearly, I am missing something.

Should I be able to interact with any open window from inside a script that is running as a service?

Can anyone explain why I can not use Winlist from a script running as a service?

Can someone provide an example as to how to run an autoit script as a service, detect when someone has logged on, and then launch a program, and then interact with it from inside the script.

Thanks for any help.

#66 NightxStalker

NightxStalker

    Seeker

  • Banned (NOT IN USE)
  • 10 posts

Posted 24 September 2008 - 02:14 AM

ok i was wondering if there was any way to detect an open process when the user logs on and close it, then to launch another program after the first process has been killed (or the window hidden)

#67 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 24 September 2008 - 08:28 AM

you have to understand two things :
- services are protected before logon to not let malicious software interact before the user login ( imagine a window that could replace the logon window ).
- SYSTEM is an account without user personification. So it can not acces to tihs layer.
- Services are made for agent or something, like antivirus. Their purpose are not to interact with windows or something.

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

 

Projects :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#68 GrahamT

GrahamT

    Seeker

  • Active Members
  • 25 posts

Posted 25 September 2008 - 02:45 AM

This is just the code I need to run a program on the computers in my school, so the kids can't it stop from running! However, I can't get it to work. When I try to compile I get this error message
C:\FREECOM\AutoIt3\GTs Programs\service.au3(178,7) : ERROR: main(): undefined function.     main()     ~~~~~^

I'm confused. My program doesn't have a Function called "main" - the main code is enclosed in a While/Wend loop. What do I do?

Thanks,
Graham

Edited by GrahamT, 25 September 2008 - 02:46 AM.


#69 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,273 posts

Posted 25 September 2008 - 03:17 AM

This is just the code I need to run a program on the computers in my school, so the kids can't it stop from running! However, I can't get it to work. When I try to compile I get this error message

C:\FREECOM\AutoIt3\GTs Programs\service.au3(178,7) : ERROR: main(): undefined function.     main()     ~~~~~^

I'm confused. My program doesn't have a Function called "main" - the main code is enclosed in a While/Wend loop. What do I do?

Thanks,
Graham

Wrap the While/Wend loop inside a Function called main().
edit:
Func main()     While 1         ;Service Code Loop         sleep(10)     WEnd EndFunc   ;==>main

Edited by spudw2k, 25 September 2008 - 03:18 AM.


#70 GrahamT

GrahamT

    Seeker

  • Active Members
  • 25 posts

Posted 25 September 2008 - 03:30 AM

Wrap the While/Wend loop inside a Function called main().
edit:

Func main()     While 1         ;Service Code Loop         sleep(10)     WEnd EndFunc   ;==>main

Great! That worked fine - and its now compiling properly.

But, when I run it in Command Prompt window with -i on the end of the file name, I get Error 1063
The program runs - but its not showing in the services list.

Thanks,
Graham

#71 GrahamT

GrahamT

    Seeker

  • Active Members
  • 25 posts

Posted 27 September 2008 - 05:48 AM

Great! That worked fine - and its now compiling properly.

But, when I run it in Command Prompt window with -i on the end of the file name, I get Error 1063
The program runs - but its not showing in the services list.

Thanks,
Graham

Anybody got any ideas on how to get this to work?

Thanks

#72 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,273 posts

Posted 29 September 2008 - 04:48 PM

Anybody got any ideas on how to get this to work?

Thanks

It may attempting to run after you install it (depending on your code). It will fail if it is run this way. Do you see the service in the service control manager? Start -> Run -> services.msc It needs to be started by the SCM.

#73 GrahamT

GrahamT

    Seeker

  • Active Members
  • 25 posts

Posted 29 September 2008 - 11:50 PM

It may attempting to run after you install it (depending on your code). It will fail if it is run this way. Do you see the service in the service control manager? Start -> Run -> services.msc It needs to be started by the SCM.

Thanks for that - yes I think it was attempting to run. Anyway, I already found a freeware program which will install it as a service:

RunAsSvc

Graham

#74 PaulBaumann

PaulBaumann

    Seeker

  • Active Members
  • 22 posts

Posted 08 October 2008 - 07:56 AM

Hi Arcker,

thanks a lot for this work.

I've been looking around for a long time for an UDF like this one. Many thanks.

Best wishes
Paul

#75 kjcdude

kjcdude

    Adventurer

  • Active Members
  • PipPip
  • 142 posts

Posted 24 October 2008 - 01:09 AM

So i've been playing with this for a while and have gotten it to work sometimes, but not all the time.

I'm running it on a windows 2003 server with the service properties adjusted to "allow service to interact with desktop".

If i use the example code it works exactly as it should, it displays a msgbox every 1 second.

But as soon as i modify the main function to the following it will not work. It runs the function, everything looks like it should be working, but it flat out does not work. The run function worked, but winwait and send also did not work.
func main()     while 1         WinClose("test.txt", "")     Sleep(1000)     WEnd EndFunc

Edited by kjcdude, 24 October 2008 - 01:13 AM.


#76 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 24 October 2008 - 09:15 AM

remember that the purpose of a service is a background process. It can't interact with desktop like others process because it runs under SYSTEM account with somes limitations.
The purpose for me was to make a Nagios agent that could be stop / restarted and controlled by the services easily.
Whenever i see a script containing window manipulation function, i can say that the script will not runs well.
Sry it's a limitation, but a good limitation, for security reasons.

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

 

Projects :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#77 ShminkyBoy

ShminkyBoy

    Seeker

  • Active Members
  • 29 posts

Posted 24 October 2008 - 03:29 PM

remember that the purpose of a service is a background process. It can't interact with desktop like others process because it runs under SYSTEM account with somes limitations.
The purpose for me was to make a Nagios agent that could be stop / restarted and controlled by the services easily.
Whenever i see a script containing window manipulation function, i can say that the script will not runs well.
Sry it's a limitation, but a good limitation, for security reasons.


so why does srvany.exe, runasssvc.exe et al allow the scripts to run with gui and everything using Bitor($service_win32_ownproccess,$service_interactive_process) [spelling probably not right, I'm going off memory here at work... my code is at home=)], but the 'native' autoit routines do not?

also I've tried to read through and figure out my own troubles (posted in other thread), and found of MSDN that there's indeed a 'main()', and that's for console apps.

.. but there's also a 'winmain()' that should be used for GUI processes?

.. also if services were flat out not allowed to interact with users, what would even be the point of having a choice to interact with desktop at all?

.. also in reading about services (I really am trying to contribute, but I'm in way over my head methinks).. there is indeed the SCM which handles the service proccess if it is a console app...

... but for GUI (ie- interactive) the service should use SCP? it this right?

here's the thread and code I'm talking about:

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


<--- confused now. Please forgive =)

#78 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 25 October 2008 - 11:30 AM

you're right, the is two types of processes.
The SCM can handle a console process so it's useful to debug a process while it's runing as process. I've not integrated for now.
I agree that it's not really easy. It took me 2 weeks ti understand the whole process and make this UDF? It was not really easy since nothing have been made before.
I don't like srvany since it just acts as a "intermediate" so i can't say what's he's doing. For me it just stats a process, and stop its two ( brutally ).
Will take a look, thx for your investigation it's always good to be curious, and really helpful for proof oc concept :P

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

 

Projects :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#79 cypher175

cypher175

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 482 posts

Posted 05 November 2008 - 01:30 PM

This is Nice..!!
Thanx for your hard work arcker, i've been waiting for this type of AutoIt feature for a while now..
Just a few questions though..

Is it possible to have the compiled script .exe, once ran from a double click, install itself as a Service without having to use CMD with the -I parameter..?? Then once Successfully installed start itself up.

And also how could we code in the configuration for the service's settings like: General, Log On, Recovery, Dependencies and all the sub-options for them Ect..??

#80 spudw2k

spudw2k

    passionately misinformed

  • Active Members
  • PipPipPipPipPipPip
  • 1,273 posts

Posted 05 November 2008 - 04:22 PM

Is it possible to have the compiled script .exe, once ran from a double click, install itself as a Service without having to use CMD with the -I parameter..?? Then once Successfully installed start itself up.

http://www.autoitscript.com/forum/index.ph...st&p=579806

Also, check these out. If the service doesn't exist when it's run is asks if you want to install it.
http://www.autoitscript.com/forum/index.ph...st&p=578259

Edited by spudw2k, 05 November 2008 - 04:25 PM.






Also tagged with one or more of these keywords: Service, 1053, 1061, compile

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users