Jump to content

Running an AutoIT script with no UI

Recommended Posts


Hello Again Legends of AutoIT

I am immensely grateful for the help I was given in creating my first script which works (almost) perfectly when logged on to a PC with admin rights.

The problem is that I need to silently install the application on to 50 PCs that do not have admin rights. We have a homemade distribution tool but basically a log on script runs, checks if your in an AD group and if you are it installs the application. The problem I have is that the user that installs the application is actually a service run as a user and this means that there is no UI.

My script doesn't seem to run correctly or at least the application is not installed and I don't know enough about AutoIT basics (yet) to know whether it can be used in this context.

I'm more than happy to give more information or share my script if this is not enough information to go on.

Thanks in advance

Share this post

Link to post
Share on other sites

@Kirky sharing your script is always helpful; if ever in question, share. As for installing as a service, it should work as long as you're not trying to interact with the desktop (or you have set the service up to interact with the desktop). Again, seeing the script would be most helpful.

√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post

Link to post
Share on other sites

Since this is a InstallShield Product you should be able to capture the settings and then use these for deployment for example:

On a new system without KeyScape installed, run the following:

KSLC_11_1_0_Setup_x64.exe /r /f1C:\Temp\KeyScape.iss

Run through the installation this should create a file named: C:\Temp\KeyScape.iss once it has completed.

Copy this file to the same path as KSLC_11_1_0_Setup_x64.exe.

Create a new AutoIt Script named KeyScape.au3 with the following:

RunWait(@ScriptDir & '\KSLC_11_1_0_Setup_x64.exe /s /f1"' & @ScriptDir & '\KeyScape.iss")

Another method is just using default settings for example:

RunWait(@ScriptDir & '\KSLC_11_1_0_Setup_x64.exe /s /v" /QB /NORESTART"')


Share this post

Link to post
Share on other sites

Thanks for your suggestions Subz I did try both of these methods first but neither work.

RunWait(@ScriptDir & '\KSLC_11_1_0_Setup_x64.exe /s /f1"' & @ScriptDir & '\KeyScape.iss")

Using this method brings up a message box towards the end of the install asking which version of AutoCAD to integrate with which is why I ended up creating the AutoIT script in the first place.

RunWait(@ScriptDir & '\KSLC_11_1_0_Setup_x64.exe /s /v" /QB /NORESTART"')

This method just hangs and nothing is installed at all.







Share this post

Link to post
Share on other sites

Installshield will create a temp directory for it's files during transition, and will also include a log file...check that out, and see what's up.

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post

Link to post
Share on other sites

The log isn't helpful:


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

  • Similar Content

    • ChipConnJohn
      By ChipConnJohn
      Hello all,
      I've scripted AutoIT to scrape a web forum I'm part of using the IE.au3 #include.  The script works great if I'm logged in, but doesn't work as a service.  Anyone have any ideas on how I might achieve that or will I have to have the computer logged in at all times?
    • musicstashall
      By musicstashall
      Excuse me, I did not understand how in the function of Main I can include hundreds of functions of my executable code ?? How to implement this?
    • wtarkan
      By wtarkan
      If I create a service to run a program , Application window cannot Appear - How can I make the App window visible
    • tremolux66
      By tremolux66
      I'm unable to display a message box from a compiled AutoIt alerting script that is executed from a service (also a compiled AutoIt script). I used $MB_SERVICE_NOTIFICATION, but the dialog doesn't appear and the alerting script continues as if the OK button had been clicked. The service script uses ShellExecute() to launch the alerter (as opposed to a *Wait() call) so it can continue processing. Note that we used Windows Service Wrapper (winsw) to turn the compiled script into a service but haven't identified any issues from it.
      I tried the one-line execute example given in this thread: Message box timeout not working
      ; 2097152 = $MB_SERVICE_NOTIFICATION $iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(2097152, ''' & $sTitle & ''', ''' & $sText & ''')"') without the timeout code, but no luck: the MsgBox does not appear. (In any case, we don't have AutoIt installed on the target system, so it would have to be converted into a .exe file.)
      We're developing and unit-testing on Win 7 Enterprise; the target OS is Win 7 Pro, and the AutoIt version is
      Any solutions or suggestions will be much appreciated. Code fragments are below.
      The following code fragment is the relevant portion of the alerting script that displays the MsgBox:
      [...] ; Alert the operator that there's a problem with the recording $sFeed = $aRecInfo[6] $sSession = $aRecInfo[2] $sTemp = $aRecInfo[4] $sDate = _FormatDate($sTemp) $sTemp = $aRecInfo[5] $sTime = _FormatTime($sTemp) _Debug2("Inactive recording feed " & $sFeed & ", Session=" & $sSession & ", Start Date/Time=" & _ $sDate & " " & $sTime) $sErrorMsg = "ERROR: Feed " & $sFeed & " for session " & $sSession & " stopped, notify reporter immediately" $iMbFlag = $MB_SERVICE_NOTIFICATION _Debug1("Displaying MsgBox...") MsgBox($iMbFlag, "INTERVIEW RECORDING ERROR", $sErrorMsg) _Debug1("Returned from MsgBox") [...]  
      And the calling code fragment in the service is:
      ; Walk through the array backwards so we don't end up evaluating an index that doesn't exist For $iIndex = UBound($aFeedArray)-1 To 0 Step -1 [...] ; Before timing-out the feed, check for a .mpgpart file (=> feed may still be recording) $sDirPath = $sDirTemp & "\" & $sFeedTemp & "\" & $aFeedArray[$iIndex][$cSessionName] $sMpgPartName = GetMpgPart($sDirPath, $sFeedTemp) If StringLen($sMpgPartName) > 0 Then ; If .mpgpart file name hasn't changed in more than $iDeadFeedTime seconds, then declare feed dead ; ========v Test code to force error v======== $sMpgPartName = $aFeedArray[$iIndex][$cMpgPartName] ; ========^ Test code to force error ^======== _Debug2("Just set $sMpgPartName to '" & $sMpgPartName & "', should fall into dead-feed code") If $sMpgPartName = $aFeedArray[$iIndex][$cMpgPartName] Then ; Name is same => feed is dead: alert the operator and delete the feed w/out stop-processing _Debug2("Feed " & $sFeedTemp & " looks dead -- alerting the operator") _Debug2("Delete GUID " & $aFeedArray[$iIndex][$cGUID]) ; ======== Alert app execution ======== ; $sAlertApp = @ScriptDir & "\" & "RecAlert.exe" $iChildPid = ShellExecute($sAlertApp, $sDirPath, "", "open") _Debug2("Alert app: ShellExecute(): " & _RetStr($iChildPid, @error, @extended)) _ArrayDelete($aFeedArray, $iIndex) Else ; Otherwise, the .mpgpart name has changed, reset the timer, store the name, and continue _Debug2("Feed " & $sFeedTemp & " timeout, but has new .mpgpart file -- continuing") $aFeedArray[$iIndex][$cDateTime] = TimerInit() $aFeedArray[$iIndex][$cMpgPartName] = $sMpgPartName EndIf ContinueLoop EndIf [...] Next  
    • arcker
      By arcker
      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 min, last beta recommended ( tested in ) 

      ++ 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,

      see end of this post : ServiceExample_v4, Services.au3, ServicesConstants.au3

      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 script Choose 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


      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.


      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 work Then 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 it net start "yourservicename" Services.msc Use 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