t0ddie Posted April 10, 2007 Share Posted April 10, 2007 (edited) im trying to run my script as a service and this is what i do, but it does not run as a service. #include "ServiceControl.au3" $servicename = "test.exe" FileInstall("srvany.exe",@SystemDir & "srvany.exe",1) _CreateService("", $servicename, "", @SystemDir & "srvany.exe", "LocalSystem", "", 0x110) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\" & $servicename & "\Parameters", "Application", "REG_SZ", @ScriptFullPath) Run("test.exe") ServiceControl.au3 is in my include folder. srvany.exe is on my desktop. test.exe is on my dektop. this script is run from my desktop. i open the task manager and test.exe is still running under my user name and does not say "service". what am i doing wrong? Edited April 10, 2007 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 10, 2007 Share Posted April 10, 2007 (edited) Hi, I did it this way: #include "ServiceControl.au3" #include "Misc.au3" ;#NoTrayIcon ; Kann man natürlich auch noch wegmachen :-) If _Singleton("MegaService", 1) = 0 Then MsgBox(64, "Warning", "An occurence of test is already running", 3) Exit EndIf Global $pathSrvAny = "c:\Downloads\AutoIt-Skripte\Entwicklung\ForumTests\srvany.exe" Global $servicename = "MegaService" If Not _ServiceExists (@ComputerName, $servicename) And @Compiled Then _CreateService ("", $servicename, "Mega Skript", $pathSrvAny, "LocalSystem", "", 0x110) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\" & $servicename & "\Parameters", "Application", "REG_SZ", @ScriptFullPath) EndIf While 1 Sleep(500) theFunc() WEnd Func theFunc() If @HOUR = 16 And @MIN = 24 And @SEC = 00 Then ; hier mal die Zeit anpassen :-) ToolTip("Skript gestartet" & " Service An(1)Aus(0) :" & _ServiceExists (@ComputerName, $servicename), 0, 0) Beep(500, 5000) Else ToolTip("Skript inaktiv" & " Service An(1)Aus(0) :" & _ServiceExists (@ComputerName, $servicename), 0, 0) EndIf EndFunc ;==>theFunc Edit: You are also missing a \ here @SystemDir & "srvany.exe" , right? So long, Mega Edited April 10, 2007 by th.meger Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
t0ddie Posted April 18, 2007 Author Share Posted April 18, 2007 (edited) Hi, I did it this way: #include "ServiceControl.au3" #include "Misc.au3" ;#NoTrayIcon ; Kann man natürlich auch noch wegmachen :-) If _Singleton("MegaService", 1) = 0 Then MsgBox(64, "Warning", "An occurence of test is already running", 3) Exit EndIf Global $pathSrvAny = "c:\Downloads\AutoIt-Skripte\Entwicklung\ForumTests\srvany.exe" Global $servicename = "MegaService" If Not _ServiceExists (@ComputerName, $servicename) And @Compiled Then _CreateService ("", $servicename, "Mega Skript", $pathSrvAny, "LocalSystem", "", 0x110) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\" & $servicename & "\Parameters", "Application", "REG_SZ", @ScriptFullPath) EndIf While 1 Sleep(500) theFunc() WEnd Func theFunc() If @HOUR = 16 And @MIN = 24 And @SEC = 00 Then ; hier mal die Zeit anpassen :-) ToolTip("Skript gestartet" & " Service An(1)Aus(0) :" & _ServiceExists (@ComputerName, $servicename), 0, 0) Beep(500, 5000) Else ToolTip("Skript inaktiv" & " Service An(1)Aus(0) :" & _ServiceExists (@ComputerName, $servicename), 0, 0) EndIf EndFunc ;==>theFunc Edit: You are also missing a \ here @SystemDir & "srvany.exe" , right? So long, Mega i am missing that "\" in the code that posted because i did it the proper way first, but i started to mess around with it to get it to work and i must have accidentally erased that. this is just what i cut and pasted after i messed with it. however the fileinstall function does not matter in this script becaue i have already put the file there manually. i added that and i also tried your code and this isnt working for me. can someone give me an example where it will take a file... and run it as a service from the script? Edited April 18, 2007 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
ptrex Posted April 18, 2007 Share Posted April 18, 2007 @allMaybe this can help you out.Run script as a serviceEnjoy !!ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
t0ddie Posted April 18, 2007 Author Share Posted April 18, 2007 (edited) i tried using it but i could not get it to work. then i read your instructions now it works. heh Edited April 18, 2007 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
ptrex Posted April 19, 2007 Share Posted April 19, 2007 @t0ddie OK good to hear it's working see you around. ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
t0ddie Posted April 19, 2007 Author Share Posted April 19, 2007 one last thing. i have adjusted the script... so that it will run a service without a gui. #include <Process.au3> Global $strComputer = "." Const $OWN_PROCESS = 16;16 is own process Const $INTERACTIVE = true;True changes the $Own_Process to 272 is interact with desktop Const $NORMAL_ERROR_CONTROL = 1 $srvany = @DesktopDir & "\srvany.exe" $script = @DesktopDir & "\test.exe" $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2") $objService = $objWMIService.Get("Win32_BaseService") $errReturn = $objService.Create("_Au3@Service" ,"_Au3@Service" , $SrvAny, $OWN_PROCESS, $NORMAL_ERROR_CONTROL, _ "Manual", $INTERACTIVE, "LocalSystem", "" ) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\_Au3@service\Parameters", "AppDirectory", "REG_SZ", @WorkingDir) RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\_Au3@service\Parameters", "Application", "REG_SZ", $Script) _RunDos("Net start _au3@service") ProcessClose("srvany.exe")oÝ÷ Ûrv¬²»Ú'±yÊ'¶)îzÚ+º|!zx²z-çyׯzvµêâ{+®øzÇ+l®ö§ÉÊ'¶)îzËh®éârZ,zÊïj|Å觵«$©ÚêÚÙ²±êïǬr¸©¶+'¢×}ç-yÛ(IèÂ+lgyç^vÚ+º|!Wë®øz++ºyâ!zx¯+hrZ,zÊïj|ÅëâjÇ+g¢ØbZ¦§²'¯z{kçZ²Ö§u©hë®*mÂ+aë-¶¬xjëh×6ProcessClose("srvany.exe") how can i end this process? it is not needed and it actually intrferes with my script. if i end the script, srvany.exe continues to run. then when i attempt to run the service script again, if i have not manually ended srvany.exe then it does nothing. any help? Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Uten Posted April 19, 2007 Share Posted April 19, 2007 srvany is a service not a "program". You have to stop it with something like net stop my au3 service Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
t0ddie Posted April 19, 2007 Author Share Posted April 19, 2007 (edited) srvany is a service not a "program". You have to stop it with something like net stop my au3 service uhm... wont that stop both srvany.exe AND test.exe?? is there a way to make these seperate services? or what. Edited April 19, 2007 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Uten Posted April 19, 2007 Share Posted April 19, 2007 didn't you want your script to run as an service? But you want to remove the service part? Thats easy,... don't run it as a service.. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
t0ddie Posted April 19, 2007 Author Share Posted April 19, 2007 didn't you want your script to run as an service? But you want to remove the service part? Thats easy,... don't run it as a service..ehm, uh.the script will run as a service....i go into task manager.i close srvany.exethe script is still running as a service.yes i would like the script to run as a service, but i dont need srvany.exe running as a service after its use has been completed.if this is not possible i will merely add the stopservice code to the beginning of the script to prevent this issue.. however thats undesirable.... Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Uten Posted April 19, 2007 Share Posted April 19, 2007 ehm, uh.the script will run as a service....i go into task manager.i close srvany.exethe script is still running as a service.No it is not. Because you have killed the service part of your script so it will not act as a service any more. It runs as a regular program under another user profile SYSTEM or what it is called these days. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
t0ddie Posted April 19, 2007 Author Share Posted April 19, 2007 No it is not. Because you have killed the service part of your script so it will not act as a service any more. It runs as a regular program under another user profile SYSTEM or what it is called these days.interesting.is there a way to run a script (not as a service) under another user profile? Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 19, 2007 Developers Share Posted April 19, 2007 (edited) interesting.is there a way to run a script (not as a service) under another user profile?What do you exactly want to do with this ? Edited April 19, 2007 by JdeB 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...
t0ddie Posted April 19, 2007 Author Share Posted April 19, 2007 What do you exactly want to do with this ?well.. i just want my file to run under the SYSTEM username. i could care less if its a service.reasons?i dont want people on my computer closing the script i have running.it runs at all times and if it closes i lose data.if its not on my username they will be less likely to close it. Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Uten Posted April 19, 2007 Share Posted April 19, 2007 You have been around long enough to know this shit by now @t0ddie. I know you don't find this comment very helpful. but hey please come on!!!! There is a really handy search link in the upper right corner of my page. Is it missing in yours? Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling Link to comment Share on other sites More sharing options...
t0ddie Posted April 19, 2007 Author Share Posted April 19, 2007 You have been around long enough to know this shit by now @t0ddie. I know you don't find this comment very helpful. but hey please come on!!!! There is a really handy search link in the upper right corner of my page. Is it missing in yours? i did a search and it came up with runasset() func but appearantly its broken?otherwise i would not have posted.thanks uten. while i did not find that very helpful, i also did not find it offending or negative.perhaps you were unaware that runasset() is broken?i have not tried runasset yet as i am heading out to go to work... but after reading the posts in my search there was no fix yet so... nice usage of the word "shit" btw Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
evilertoaster Posted April 19, 2007 Share Posted April 19, 2007 http://blogs.msdn.com/adioltean/articles/271063.aspxhttp://www.tech-recipes.com/windows_tips1288.htmlThose are some links that describe how to run a program as the system account. It is not somthing you would tipically do, and there may also be some code snippets in example scripts that can do this feature. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 20, 2007 Developers Share Posted April 20, 2007 (edited) i did a search and it came up with runasset() func but appearantly its broken?otherwise i would not have posted.thanks uten. while i did not find that very helpful, i also did not find it offending or negative.perhaps you were unaware that runasset() is broken?i have not tried runasset yet as i am heading out to go to work... but after reading the posts in my search there was no fix yet so... nice usage of the word "shit" btwHow did you come to the conclusion that RunAsSet() is broken... and if you conclude that, why not report your "real" problem in stead of trying to make a Mickey-mouse solution?Now, don't go run of and post a Bug-report, but post the "real" problem you have here.... Edited April 20, 2007 by JdeB 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...
Uten Posted April 20, 2007 Share Posted April 20, 2007 ....Or at least add a link to the topic claiming RunAsSet is broken. Every time I have experienced problems with RunAsSet it has been due to my own ignorance of how it works. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling 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