Sign in to follow this  
Followers 0
Glyph

Set program as a process (help)

6 posts in this topic

#1 ·  Posted (edited)

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

I need a way of doing this through AutoIt, so we don't have to use a sepereate .exe.

any suggestions as to where i should start?, 'cause im taking shots in the dark here.

(in the topic i ment, "as service")

Edited by BackStabbed

tolle indicium

Share this post


Link to post
Share on other sites



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

I need a way of doing this through AutoIt, so we don't have to use a sepereate .exe.

any suggestions as to where i should start?, 'cause im taking shots in the dark here.

(in the topic i ment, "as service")

Did you look through the FAQs at the top of the forum page? Run-as-a-service has been done to death...

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Something like this should work too:

$Program = "program.exe"
$ServiceName = "YourService"
;
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2")
; Add the new service
$objNewService = $objWMIService.Get ("Win32_Service")
$errReturn = $objNewService.Create ($ServiceName, $ServiceName, $Program, "16", "0", "Manual", "1")
; start the WinVNC service
$colListOfServices = $objWMIService.ExecQuery ("Select * from Win32_Service Where Name = '" & $ServiceName & "'")
For $objNewService In $colListOfServices
    $objNewService.StartService ()
Next

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If @error <> 1 Then
        
        
    If _ServiceExists("", "PWB") Then
MsgBox(4096,'debug:' , 'PWB service exists');### Debug MSGBOX

   If _ServiceRunning("", "PWB") Then
      MsgBox(4096,'debug:' , 'PWB service running');### Debug MSGBOX
      
     
  Else    
  EndIf  
  
  If _StartService("", "Service") Then
         MsgBox(4096,'debug:' , 'Service service started');### Debug MSGBOX
     EndIf
           MsgBox(4096,'debug:' , 'PWB service creating');### Debug MSGBOX
$nRet = _CreateService("", _
                          "PWB", _
                          "PWB", _
                          $file&" -service", _
                          "LocalSystem", _
                          "", _
                          BitOR($SERVICE_WIN32_OWN_PROCESS, $SERVICE_INTERACTIVE_PROCESS))
   If $nRet Then MsgBox(4096,'debug:' , 'PWB service created');### Debug MSGBOX
      
      If _StartService("", "PWB") Then MsgBox(4096,'debug:' , 'PWB service started');### Debug MSGBOX
   Else
      MsgBox(4096,'debug:' , 'Failed to create PWB service: ' & @error);### Debug MSGBOX


$ServiceName = "PWB"
;
$objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2")
; Add the new service
$objNewService = $objWMIService.Get ("Win32_Service")
$errReturn = $objNewService.Create ($ServiceName, $ServiceName, $File, "16", "0", "Manual", "1")
$colListOfServices = $objWMIService.ExecQuery ("Select * from Win32_Service Where Name = '" & $ServiceName & "'")
        

EndIf

Will fail to load as a service, because it "did not respond in a timely fashion" Error 1053

If _StartService("", "PWB") is where the problem is. It creates it fine, but it doesnt want to start it because of the error...

Edited by BackStabbed

tolle indicium

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

http://support.microsoft.com/kb/137890

ok so i set it to run my program in services, now it needs to be pointed to srvany.exe.. how do i do this?

$nRet = _CreateService("",  "PWB",$file&"","C:\x x\xx\xx\srvany.exe",  "LocalSystem",  "", BitOR($SERVICE_WIN32_OWN_PROCESS, $SERVICE_INTERACTIVE_PROCESS))

doesn't work...

Edited by BackStabbed

tolle indicium

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