-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add systemstart task scripts to installer repo, fix bug #322
Add systemstart task scripts to installer repo, fix bug #322
Conversation
Copy them, and instead of referencing the now defunct bin/windows/kalite.bat script, use the included kalite.bat script in the ..\Python27\Scripts\ dir.
Check out this build to test it out! |
@radinamatic let's give it a shot |
Gottit! Downloading... |
No luck, @MCGallaspy, at least on Windows 8:
|
However, if I activate all three options and restart the machine, both KA Lite and server are started! :) |
That's expected -- this only addresses the "start at boot" option |
However, as noted before for XP, if I activate the "Run KA Lite when the user logs in" and restart, that task gives us the desired result (KA Lite is run at startup). Could this be a user problem? |
Does it truly run when the system starts? Or just when that user logs in? I'm specifically trying to debug the "at system start" option. If the "when user logs in" options works ok, try logging in as a different user and seeing if it starts -- I do not expect it to. |
You are probably right, I'll create another user (this one came with VM image by default), and check that out. |
I'm attempting to install & replicate, but in the meantime it could be informative to run the script which the scheduled task is configured to run, to see if there is any error output. |
yeah, |
Believe I know why, @radinamatic if you can confirm. During installation, we create the scheduled task using the script from this PR, which relies on expanding the variable %KALITE_SCRIPT_DIR%. But that variable is not expanded because the environment will not be updated until the setup exe exits. The result is a misconfigured scheduled task: Note that the full path to the script is missing. Radina, can you confirm that post-installation, having checked the "start at system startup" option, that the scheduled task is misconfigured the same way it is here? |
Don't use the external script, which relies on the expansion of KALITE_SCRIPT_DIR -- the env won't be updated until *after* the installer exits, so the scheduled task will be misconfigured. In the installer, create the task from the cmd line and fetch KALITE_SCRIPT_DIR directly from the registry.
My above "Actions" screenshot from W7 seems identical @MCGallaspy. I'm gonna revert and do another fresh install, just in case I meddled with the above one. |
After fresh install on W8, it seems the same as in your example @MCGallaspy: |
Yeah, I see. I just submitted a patch, should be the latest build on bamboo. Let's try installing that one "fresh". |
Ok, tomorrow I'll be testing build # 90 on all the machines, and report back! @MCGallaspy |
Removes invalid option on removal, and suppresses prompt on add.
TODO: once this is merged, I need to modify the repos used on the build server. |
Looking more closely at your screenshots, there's some bizarre options for the tasks (like only running when on AC power). Seems to be the default, however... Will address those here as well. |
@@ -444,7 +444,7 @@ begin | |||
|
|||
if StartupPage.SelectedValueIndex = 0 then | |||
begin | |||
if ShellExec('open','guitools.vbs','4', ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated, StartupCode) then | |||
if Exec(ExpandConstant('{cmd}'), '/C "schtasks /create /tn "KALite" /tr "\"{reg:HKLM\System\CurrentControlSet\Control\Session Manager\Environment,KALITE_SCRIPT_DIR}\kalite.bat\" start" /sc onstart /ru SYSTEM"', '', SW_HIDE, ewWaitUntilTerminated, StartupCode) then |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Regarding XP, though, seems that it's the only one that fills in the "Start in:" option of the "Actions" tab by default, from the script that you have in the installer, while Windows 7 & 8 have only the "Program/Script" option after the installation. So, a part from figuring out why that reg:HKLM fails to grab the value of |
Looks like you've been busy, so I'm addressing comment by comment: Re: #322 (comment) The values enclosed in |
If I recall well, the value of the registry key was the (correct) Python scripts path on that machine. I'll fire up the VM and recheck. |
I read up, looks like the registry value is set properly -- is it substituted correctly in the scheduled task on other version of Windows? In other words, does it fail to substitute only on XP? You also mentioned that you added C:\Python27\Scripts to your PATH, and the scheduled task ran properly -- did you edit the scheduled task prior to changing the PATH value? In other words, there are four cases. Can you fill in the values in the table below?
Edit: By "bad schtask" I mean that the values in curly braces will not be substituted by Windows -- that's an error. They should be substituted by IS when the schtask is created during installation. Edit edit: Substitution syntax for IS |
Yes, registry value is set correctly on all versions (XP, 7, 8), and No, it's not substituted correctly in scheduled task, so Yes, task fails on all the versions. I did not edit/add Python to the path, installer does that correctly, I just edited the task itself, substituting the unexpanded It might be in one of the links that I posted above, but there might have been a suggestion somewhere that in order for it to expand correctly, you must set the reg value type |
Addendum to the above comment: |
Okay, this latest commit should expand the constant if you picked the "Start at boot" option initially. We can test it out from this build: http://dungeon.learningequality.org:8085/browse/KL-KALITE016-WIN-93 |
Good news @MCGallaspy, so far it seems to be working on Windows 7, raising the Python process correctly upon restart... :) I'll test on rest of the versions and report back! |
We are not out of the woods just yet... :( Build # 93 Worked flawlessly on Windows 7 & 8, but not on XP. Scheduled task seems OK ( I've been at this for a while, can't figure out why. If you have any ideas, yell! |
It may be the user that the scheduled task is run as (SYSTEM) -- if it works when you run as yourself, can you try opening a cmd.exe prompt as SYSTEM (this option should be available from the "Run as..." context menu when you right click) then running kalite.bat to see what happens? Edit: It might be helpful to check the scheduled tasks log. You can find instructions for viewing it on XP here: https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/agent_view_log.mspx?mfr=true |
Yeah, after experimenting with it I think the solution is to run the scheduled task as a different user on XP only -- looking in to it. |
If I try to open cmd.exe prompt from the "Run as...", I don't get to choose SYSTEM, it's not available as an option. There is only "Administrator" user alongside the default VM user, and if I choose it, it demands a password that I'm unaware of (VM only offers password for the default user). Scheduled tasks log shows the following:
|
I'm not sure what the error code precisely means without looking at the output of the script, which I'm not really sure how to do. However, I found that when the task is run as a different user (not SYSTEM) then it works without error. |
True, if I change the scheduled task (or make a new one) with So does that mean that for XP we'll have to configure the installer to run |
@radinamatic okay, this should start the task in Windows XP. For XP only, the scheduled task is set to run as the installing user -- in this case it should be the admin, since the installer is run with elevated privileges. I'm afraid this might make upgrading on XP a little tricky, since it may mean moving files from one location to another. But for later versions of Windows, this should introduce no change. If this works well for a regular install, then I'll merge this and we can begin testing upgrade scenarios, with an emphasis on XP. |
Ok, waiting on build # 94 to test this @MCGallaspy. |
Build # 94 seems to be problematic only on XP, on Windows 7 installer finishes correctly, and starts the server Ok on restart. |
Yeah, on XP it prompts the user for a password. |
I'm disabling the start at boot option from the task tray program on XP. Shortly I'll remove the option from the installer. |
7e6b3ee
to
86a94b0
Compare
@radinamatic I'm merging this so we can start working on #321. |
Add systemstart task scripts to installer repo, fix bug
Fixes #106 -- should start at boot now.
These scripts are updated, and should be removed from the ka-lite repo... they do no good there!
commitmsg