Jump to content

Task Launched with Task Scheduler


Recommended Posts

Im currently working on automating our installers for an application we make to deploy to our development environments. I have so far been able to automate the entire installer, capturing and entering information that is needed and sending out proper emails. All works great when I am actively logged into the remote computer (using RDC, remote desktop connection). It also works if I am not logged in with RDC but the user is still logged into the box. But the problem happens when I kick the script off through task manager and a user isn't logged in.

This is what is happening.

1) Script executes (i compiled it to an .exe) and does my file manipulation stuff and read settings files fine.

2) it then goes to execute an exe which will produce a window (

$ServicesInstallerPID = Run("msiexec /package "&$InstallerRootDirectory&"\Services_"&$VersionNumber&"\LogosServices.msi",$InstallerRootDirectory&"\Services_"&$VersionNumber)

to be exact)

3) I then search for a window that i know should exist, but it will never find it. Here is how im trying to find the window..

While 1
    ;   Debug("Looping for windows")
        sleep(1500)
        $title="LogosServices - InstallShield Wizard"
        $message="The InstallShield(R) Wizard will install LogosServices"
        $handle = WinGetHandle($title,$message)
        If not @error Then
            Debug("Found Main Window")
            WinActivate($handle)
            WinWaitActive($handle,$message,60)
            Debug(@TAB&"*CLICK*")
            ControlClick($handle,"",3477)
            sleep(200)
        EndIf   
WEnd

i think this has something to do with not having an gui session logged in (or something like that). Is there a way around this without having an actively logged in user?

Link to comment
Share on other sites

Windows can be created and found (i.e. WinGetHandle() should work), but no window can be active without a desktop so WinActivate() and WinWaitActive() won't work. If ControlClick() still works with the window not active, it shouldn't stop you.

:mellow:

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

Windows can be created and found (i.e. WinGetHandle() should work), but no window can be active without a desktop so WinActivate() and WinWaitActive() won't work. If ControlClick() still works with the window not active, it shouldn't stop you.

:mellow:

You may be correct on the WinGetHandle and that it should be working.

For some reason my msiexec command seems to be failing....or something. I start it and get a PID. Then after 1 min of sleep, i check to see if the process still exists and it is gone. There should be a dialog waiting for some info....

I need to do some more research to see what is actually going on.

Link to comment
Share on other sites

Ok. Got a lot more info here.

Running the following code produces the exact problem i am having. Run this while logged on and it will generate some text for the calculator process. Then afterwards delete the c:\test.ini file and schedule the task to run (give it credentials to run), then log off all active sessions before the task runs. Log back in after the task has run and view your file. The window has no text.

$InstallerPID = Run("calc")
sleep(500)
$title="Calculator"
$message="Backspace"
If WinExists($title) Then
    IniWrite("c:\test.ini","main","Found","True")
Else
    IniWrite("c:\test.ini","main","Found","False")
EndIf
ProcessGetWindows()
Func ProcessGetWindows()
        Local $WinList = WinList()
        Local $WindowTitle[1][2]
        Local $x = 0
        For $i = 1 To $WinList[0][0]
            IniWrite("C:\test.ini",$WinList[$i][0],$WinList[$i][1],WinGetText($WinList[$i][1]))
        Next
EndFunc

example output

[main]

Found=True

[Calculator]

0x000A0384=

0x000203B4=

0x00020362=

[CalcMsgPumpWnd]

0x00060392=

0x000203B6=

0x000B034C=

[AutoIt v3]

0x001C0040=

any way to, well, ummm, work around this? Say for this example i wanted to click the 1 + 1 = buttons?
Link to comment
Share on other sites

Have you checked the installation documentation or AppDeploy for a silent install option? Since it is an MSI file used for the installation then the standard MSI commandline switches would apply and you would need to know what the "PROPERTY=" values are to use in the commandline. Also, the installer may use an INI file instead, for installation settings, that most likely would be mentioned in the installation documentation.

I have noticed that this is an InstallShield installation from your script. Is there a setup.exe or some other EXE bootstrapper in the installation directory as the MSI? Depending on the version of InstallShield used, you could create an answer file to distribute with the installation by using the following command line

setup.exe /a /r /f1c:\temp\setup.iss
Then you could run the silent installation with the following command line
start /wait setup.exe /s /a /s /sms /f1c:\temp\setup.iss
from within the script. If this doesn't work for the version of InstallShield used, then there are other silent install options depending on the version.

With a silent installation, you do not have to worry about automating the GUI or having a user logged in. This would solve your problem. If I have to do a major push, I try to do it with the silent option, if the installer allows it. Quite a few do, including the one you are using. If I have to automate the GUI, I do a autologin installation, as you mentioned.

Adam

Link to comment
Share on other sites

Ill give this a look to see exactly what we are using and if this is possible. Thanks for your advice.

Have you checked the installation documentation or AppDeploy for a silent install option? Since it is an MSI file used for the installation then the standard MSI commandline switches would apply and you would need to know what the "PROPERTY=" values are to use in the commandline. Also, the installer may use an INI file instead, for installation settings, that most likely would be mentioned in the installation documentation.

I have noticed that this is an InstallShield installation from your script. Is there a setup.exe or some other EXE bootstrapper in the installation directory as the MSI? Depending on the version of InstallShield used, you could create an answer file to distribute with the installation by using the following command line

setup.exe /a /r /f1c:\temp\setup.iss
Then you could run the silent installation with the following command line
start /wait setup.exe /s /a /s /sms /f1c:\temp\setup.iss
from within the script. If this doesn't work for the version of InstallShield used, then there are other silent install options depending on the version.

With a silent installation, you do not have to worry about automating the GUI or having a user logged in. This would solve your problem. If I have to do a major push, I try to do it with the silent option, if the installer allows it. Quite a few do, including the one you are using. If I have to automate the GUI, I do a autologin installation, as you mentioned.

Adam

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...