Jump to content

Help with udf from Example Section.. Service.au3


Recommended Posts

In the Example portion of this forum there is an Service.au3. I have followed the instructions to the "T" and not sure what I am doing wrong if any.

The only code changes I made were to the example so as to see some sort of proof I got it correct.

func main()
    while 1
;doing what you want here
    msgbox(0,"","ok");This is where I removed the ";" comment tag
    Sleep(1000)
    WEnd
EndFunc

I compile example to "test.exe"

From a command line "test.exe -i"

Installing service, please wait

Installation of service successful

I use service.msc to start the service and nothing happens other then a message box that says "Error 0" with "OK" option

I think maybe I should run test.exe again with no switch. Still "Error 0" with "OK" option.

I re-read the thread and I get the point how this is not supposed to be a gui type app so maybe the message box from the service is a bad idea

I write a quick exe that is just a message box on it's own

Message ()

Func Message()
    MsgBox(0, "Title", "Test",2)
    wait()
EndFunc


Func wait()
    sleep(10000)
    Message()
EndFunc

I test MsgBox.exe and runs fine. I even write a another app "test4.exe" to just make sure I can call MsgBox.exe

Run("C:\Projects\temp\MsgBox.exe","")

Works fine.

So I change the Service_Example to:

func main()
    while 1
;doing what you want here
    Run("C:\temp\MsgBox.exe","")
    WEnd
EndFunc

Yes, MsgBox.exe is in the c:\temp\ dir.

Still "error 0"

What am I doing wrong?

N0 I am not running an of this from SciTE. This is all via the compiled script.

I think I have all my ducks in a row. Please let me know if I am missing any information for troubleshooting this.

As always, thanks!

Edited by evilpacketmonkey
Link to comment
Share on other sites

Read the FAQ for the exact one I use.

This starts APACHE Service for me (when I want it to).

#include "Service.au3"

Dim $nRet

; Stop/start the Apache2.2 service
If _ServiceExists("", "Apache2.2") Then
  ;MsgBox(4096,'debug:' , 'Apache2.2 service exists');### Debug MSGBOX  
      If _StartService("", "Apache2.2") Then
         MsgBox(4096,'debug:' , 'Apache2.2 service started');### Debug MSGBOX
      EndIf
Else
   MsgBox(4096,'debug:' , 'Apache2.2 service does not exist');### Debug MSGBOX  
EndIf

Sleep(1000)
Link to comment
Share on other sites

while 1

;doing what you want here

msgbox(0,"","ok");This is where I removed the ";" comment tag

Sleep(1000)

WEnd

This looks like an infinite loop. What are you trying to accomplish? It should pop up the msgbox every 1000secs .

Link to comment
Share on other sites

while 1

;doing what you want here

msgbox(0,"","ok");This is where I removed the ";" comment tag

Sleep(1000)

WEnd

This looks like an infinite loop. What are you trying to accomplish? It should pop up the msgbox every 1000secs .

That is not my code, that is the code from the author of the Service.au3. http://www.autoitscript.com/forum/index.ph...st&id=22211

I finally got some time to make sure I did not miss anything in the FAQ that BrettF was referencing and he is using a different method/author/.au3 then what I am asking about in my first post.

What am I trying to do? Get the service.au3 to work, all I am trying to do at this point is just get the example script to work, even if all it does it throw a bunch of msgbox windows up. I can't get that to work.

Larger question of what I am trying to do?

I help maintain a test rack of machines at work and we want the service to monitor a (intranet) website , first download then launch that file. We are using the local MAC address to name the file on the server. First package is a app that changes hostname and IP then updates Bginfo with a custom .bgi file (it displays who has the machine checked out and for how long). I have 98% the code written except for the part where it's a service. We plan on adding it to our ghost images so when box is imaged and the setup.exe has not run yet it will. Updating the one place packages are stored on webserver is easier then trying to maintain all the ghost images.

None of what I am trying to do requires user interaction , but I am just trying to get the test example to work.

^_^

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...