Glyph Posted August 3, 2007 Share Posted August 3, 2007 (edited) http://www.autoitscript.com/forum/index.php?showtopic=44969I 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 August 3, 2007 by BackStabbed tolle indicium Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 3, 2007 Share Posted August 3, 2007 http://www.autoitscript.com/forum/index.php?showtopic=44969I 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 Link to comment Share on other sites More sharing options...
Glyph Posted August 3, 2007 Author Share Posted August 3, 2007 (edited) http://www.autoitscript.com/forum/index.php?showtopic=37289I dont want to use the .exe to register the service through smc though.I want to do this completly in autoit. Edited August 3, 2007 by BackStabbed tolle indicium Link to comment Share on other sites More sharing options...
Developers Jos Posted August 3, 2007 Developers Share Posted August 3, 2007 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 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Glyph Posted August 4, 2007 Author Share Posted August 4, 2007 (edited) expandcollapse popupIf @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 August 4, 2007 by BackStabbed tolle indicium Link to comment Share on other sites More sharing options...
Glyph Posted August 4, 2007 Author Share Posted August 4, 2007 (edited) http://support.microsoft.com/kb/137890ok 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 August 4, 2007 by BackStabbed tolle indicium Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now