Leaderboard
Popular Content
Showing content with the highest reputation on 06/09/2019 in all areas
-
Set Log On Informations for a service
RestrictedUser and one other reacted to TheXman for a topic
You can use the SC.exe command. If the service already exists, then the "SC Config ..." command will allow you to modify the account name and password. Type "SC Config" in a CMD console or Google the SC command for more information.2 points -
Or has an "App Path" value HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths. The easiest way to test if an executable can be run is to use the following: Click: Start + Run or Windows Key + R and type the name of the executable, if it runs then it doesn't require a path. If it fails, you might be able to get the file path via registry (if it's an installed software product), just search through registry for .exe and try and find a common key that all machines would use.2 points
-
_Service_UDF v4 : Build your own service with autoit code
cramaboule reacted to arcker for a topic
I can't be responsible for any impact of your script or services you would run in production. | _Services_UDF v4 | | By Arcker | Run your script as a service | Req. AutoIt 3.3.8.1 min, last beta recommended ( tested in 3.3.9.21 ) |_______________________________________ ++ Preparing v5 !! Checked on 27/04/2015 <> Updated on 10/23/2013 <> Updated 07/29/2013 <> Best practices Updated 24/02/2012 -- Removed GUI code, and old codes. == Warning : 26/02/2012 <> New Version (v3 ) : 29/07/2013 | Thx to ShminkyBoy, wraithdu, Udgeen and HolmesShelock for their great contributions. Special thx to bitboy, Downloads see end of this post : ServiceExample_v4, Services.au3, ServicesConstants.au3 Presentation Here is my _Service _ UDF With this UDF, you can compile your autoit script and run it as service. Any comments are welcome. Hope you'll like it, 1 - changelog Update V4 : 23/10/2013,27/04/2015 Update : V3 on 29/07/2013 Compile the service example to see how to do then you can use the main function for your proper scriptChoose an appropriate location and copy the script here.open a command prompt, and execute the compiled script with option –I ( must be admin right since vista )start / execute "services.msc" . You will see a service called "Autoit_service". you can execute "sc query" in a command prompt too.Launch it : it will run the previous compile script. The main function will be executed after the service_init.stop and relaunch the service as you wish. Examples / Session Change / uses v1 (lock, logon, etc) By HolmesShelock. Awesome work. Edit : this example doesn't use v2 or v3 method SessionChange Service.zip Example output to give you an idea Examples demos Synoptic And for End Users, I've tried to explain the service control manager and the way it works with programs. see below Best Practice, by arcker : /! please read this if you encounter stability issues I've had to rework on services.au3 to reflect threadsafe. Threadsafe means each dll call must be on "dllopened" instead of calling dll directly for example, if you need a function in kernel32.dll, you have to open it and call it after. That's contraignant since a lot of integrated functions in autoit are not programmed this way. If you take my services.au3, at the end, you'll see reworked function to handle this change. I've not tried services for a while, since i don't need it for now, but i can help you only if your provide whole script, to see how you call every functions. I can tell that fix stability issues in callback, but i don't think it's need for your script, as far as you don't use callback. Best Practice, by udgeen : Good news! Probably i've found the working method of integrating service.au3 with other projects I realised it after ASock.au3 project by Zatorg (please, sorry if im wrong) - ASock is asynck socket - tcp on event (uses ws2_32.dll). Asock & sqlite didnt work together. The only reason for that was..._ArrayDisplay() func with gui!!! Ok. I made special sqlite.au3 without dependences. It works, but my udf seemed too be much heavy to use at another project. Few weeks ago I returned to service.au3 and found TCP UDF, Event driven project based on ASock.au3. It seemed to work as example, but didn't work at all as service. In my variant of service_example.au3 i posted msdn words about service_main procedure, that it must contain all global vars of project I'll try to post that project as an another service_example.au3 in some weeks here. If it will works. Some advice: use SysInternals Process Explorer (free gui based), or kill.exe from support tools to stop suspended service process. U can start-stop service even net start/net stop commands. Use file logging while debuging. No need to install-uninstall service after every recompilation: only stop, recompile, start. See, if it was suspended (while stopping) - kill process. The only reason not to stop service correctly i've found for today is unclean exit: opened sockets, maybe some dlls. Edit : Arcker note: too bad, that would be too easy. unclean exit is not due to opened dll, but by some more internal exit checks or something. FAQ. 1 - Hey, I've got error 1063 or error 0, what does that mean ? It simply means that you intend to run your script in scite or directly by executing it. Your script has to be installed as service and run from it. Several ways to do it : You have to combine all Globals in one place: for example at the the begining. You have to make it with other udfs too... silly workThen sort Global Const and other Global statements. If u see something like global $x = 1 do that way: global $x leeve at top. $x =1 insert into module's (udf or project) Init func.U have to do it even with standart udf... or use only necessary functions from it in your own include. Or... maybe u have another plan?Try to build your project with modified udfs - does it works now? Hmm... But it have to Maybe later after everything will work fine i'll say "msdn is wrong, microsoft lies"... But maybe i'll say that microsoft - is not so bad, because autoit works in itnet start "yourservicename"Services.mscUse API provided _Service_start, Service_stop. 2 - I want to make a GUI ! It's not possible in a service. Create another process and communicate with your service by using IPC. 3 - I've to let the main function that way ? That's contraignant. Hey, a script intended to run as service is special no ? Autoit is not C++. The only way to have a "Main" in autoit is to have a function. If you find another way, please share it ServiceExample_ThreadSafe.au3 Services.au3 ServiceExample_v4.au3 ServicesConstants.au31 point -
@Werty: I used WinRAR v5 compression engine with latest WinRAR version. I just downloaded the archive and test was successful. With latest z-Zip it works, too.1 point
-
Set Log On Informations for a service
RestrictedUser reacted to Earthshine for a topic
yes, SC is awesome. built right into windows. you can create or modify using it as mentioned above. I second that suggestion.1 point -
Set Log On Informations for a service
RestrictedUser reacted to water for a topic
Never used it myself, but this Service UDF might solve your issue.1 point -
Here is more simple solution without _GUICtrlEdit_xxxx(): #include <GuiEdit.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> Global $hGUI, $Exit Local $logs, $String ReadOnlyGUI() Func ReadOnlyGUI() Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 625, 480, -1, -1, $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_MINIMIZEBOX + $WS_EX_TOOLWINDOW) GUISetOnEvent($GUI_EVENT_CLOSE, "Exits") GUISetState(@SW_SHOW, $hGUI) Global $ReadOnly = GUICtrlCreateEdit(" ReadOnly" & @CRLF, 400, 50, 200, 400, +$ES_READONLY + $ES_MULTILINE + $WS_BORDER + $ES_AUTOVSCROLL) GUICtrlSetStyle($ReadOnly, 0) EndFunc ;==>ReadOnlyGUI Func SetLogs($String) $logs = GUICtrlRead($ReadOnly) $logs &= @CRLF & " " & $String GUICtrlSetData($ReadOnly, $logs) EndFunc ;==>SetLogs Func Exits() Exit EndFunc ;==>Exits While 1 Sleep(1000) SetLogs("Testing") WEnd1 point
-
Positions of searchstring in a string
Earthshine reacted to iamtheky for a topic
a matter of speed sure, but not confined to this context. I had not really ever considered these things beyond regex -vs- non-regex, now I kind of want to order the string* functions from fastest --> slowest.1 point -
I don't agree I didn't know that it was matter of speed... I would have suggested this Func mikell() Local $r = "", $len = Stringlen($key), $x = 1 - $len While 1 $x = StringInStr($String, $key, 1, 1, $x + $len) If $x = 0 Then ExitLoop $r &= $x & ',' Wend Return StringTrimRight($r, 1) EndFunc ;==>mikell1 point
-
This is a too common misconception. Tell them they walk on a path that does not lead to the top of the mountain. Most (if not all code) analysis tools can be viewed —in the very best case only— as "assigning meaning to programs" after the facts, in the sense of R. Floyd. This is exactly the same thing as trying to understand in great details all the semantic subtilties of a significantly large Klingon text, by just knowing the Klingon alphabet. Obviously such approach gains you zero guaranteed knowledge about the dangerousness of the actual Klingon intents against your planet or civilization. Monthly (weekly, daily) "vulnerability patches" from MS and others illustrate the fact. If your client really cares about security and correctness of the programs they want to use, they should think the opposite way: "assign programs to meanings": https://www.researchgate.net/publication/220695256_The_B-book_-_assigning_programs_to_meanings I don't expect generic IT staffs to go that route so the best you can do if setup a code review task force on the AutoIt source or write a formally proven correct B0 to AutoIt converter and re-develop the project with B method, down to proven-correct AutoIt code. Just get warned that the latter way isn't completely trivial.1 point
-
; Display EXE names location $sExename = InputBox("", "Enter EXE name.", "Autoit3") Send("#r") Sleep(500) Send("cmd{ENTER}") Sleep(500) Send("dir c:\" & $sExename & ".exe /s /b{ENTER}") Sleep(500) MsgBox(64 + 262144, Default, "Press OK to exit.", 0) Send("Exit{ENTER}") ; end of scipt0 points