Announcement

Collapse
No announcement yet.

Web Ini Editor / Restart Homeseer Updates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Web Ini Editor / Restart Homeseer Updates

    This ASP will allow editing of any ini file in the \Config folder from a web page. It also provides the option of restarting Homeseer from the web location whichh is sometimes needed after editing an ini file.


    Version 2 of the script adds the button to restart homeseer and handles the cases of non-alpha keys in the .ini file.

    RestartHomeseer.exe will first use the hs.shutdown method to stop homeseer, it will look for 2 minutes for the window to disappear. After that it will send a message to the process politely asking for it to finish up and close itself down. About 30 seconds later if the window is still present it will kill the process in which homeseer is running. It will then start homeseer.exe.

    If the restart homeseer button is used from the asp, then the connection with homeseer will, of course, be lost. After homeseer restarts the web connection can be reestablished.

    This is quick asp I put together to edit the fields of an ini file in the \Config directory. I was going to do a web interface for the mcsTemperature plugin for the setup page, but found it much simplier to just do a generic one to allow the ini settings to be edited with a browser. I'll add a control that starts a new process that will shutdown and restart homeseer to allow the ini setting that require a homeseer restart to be recognized.

    Usage:

    Install mcsIniEditor.asp in \HTML directory
    Install RestartHomeseer.exe in homeseer directory
    Select browser's URL to homeseer server path to this file (e.g. http://192.168.1.1:8080/mcsIniEditor.asp)
    Select ini file from pulldown control
    Edit any ini value(s) on page
    Click the "Write" button to save the changes made

    Updates:

    2.1 Add timeout parameter to RestartHomeseer.exe
    2.1 Add guest check and redirect if a guest
    2.2 Look for homeseer.exe process rather than homeseer window
    Attached Files
    Last edited by Michael McSharry; December 3rd, 2005, 12:59 AM.

  • #2
    Michael,

    As always, an excellent job on this asp.

    Can I suggest that you add some code to prevent guest access? For a page that can alter settings, this could be a bit dangerous if you allow guest access.

    I have already added it to my copy but others may not be aware of this.

    Jon
    Jon

    Comment


    • #3
      Jon,

      Is something like this what you did?

      If lcase(Request.ServerVariables("AUTH_USER")) = "guest" Then
      Response.redirect ("/unauthorized.asp")
      End If

      Comment


      • #4
        Michael,

        Although that works, it gives an opportunity for the page to be displayed briefly before being re-directed.

        What I do in my asp's is to use:

        If lcase(Request.ServerVariables("AUTH_USER")) <> "guest" then

        'Main code here

        else
        Response.Redirect("/unauthorized.asp")
        end if
        Jon

        Comment


        • #5
          Michael,

          I've noticed that Restarthomeseer.exe does not always give enough time for Homeseer to shut down and tries to restart it too early. You then get the msgbox up stating that Homeseer is already running. If doing this remotely, its a disaster!

          It is now even worse with HS2 especially as I close the speaker application down with the shutdown script. Is there any way to extend the restart time or maybe add a switch/value command to define this time?
          Jon

          Comment


          • #6
            I updated to include a parameter to the .exe which is then number of minutes to wait. The asp now contains this parameter with a default of 4 minutes. I think I used 3 if no parameter is provided. I ran it with HS1, but my restart was less than 1 minute so not a good test of the timeout. I also added your code for the redirect on guests.

            Comment


            • #7
              Much appreciated Michael. I'll try it tomorrow.
              Jon

              Comment


              • #8
                Originally posted by jon00
                Michael,

                I've noticed that Restarthomeseer.exe does not always give enough time for Homeseer to shut down and tries to restart it too early. You then get the msgbox up stating that Homeseer is already running. If doing this remotely, its a disaster!

                It is now even worse with HS2 especially as I close the speaker application down with the shutdown script. Is there any way to extend the restart time or maybe add a switch/value command to define this time?
                I am seeing this everytime. I get the pop up saying Homeseer is already running?
                Thanks Jim

                Comment


                • #9
                  That is the reason for the last update. Just edit the .asp file and change the wait delay that is passed into the restart exe.

                  Comment


                  • #10
                    Thanks for your reply.

                    I have the updated version (I think) That Value is set to four.


                    ' Change value of "WaitForHSMinutes" to alter timeout before HS is restarted if HS does not shut down normally

                    Const WaitForHSMinutes = 4

                    Dim rst

                    Comment


                    • #11
                      Are you indicating that it is not waiting 4 minutes or that you are going to try 4 minutes? Or is it that hs is really not fully shutdown before it is restarted? I think I'm looking for homeseer.exe in the process list to know if it is running.

                      Comment


                      • #12
                        It is not waiting 4 minutes

                        I have coppied the above from the asp page that I downloaded today and have not edited it.

                        Comment


                        • #13
                          I looked at the source and see that I'm looking for a window with the name Homeseer in it and when it does not exist then HS is considered not running. I suspect under HS1 there may be a period between when the window closes and the ActiveX actually shuts down. In the case of HS2 there may not even be a window.

                          I dont have my HS2 disk installed right now. What I will do is look for the proceses to not exist. Can you telll me what the process name is for HS2. You can get it from Task Manager under the Process tab.

                          The timeout value of 4 is the time to wait to force HS to shutdown if it does not shutdown gracefully.

                          Comment


                          • #14
                            The process name for hs2 is HomeSeer.exe thanks

                            Comment


                            • #15
                              I changed it to look for the process rather than the window title. Tested on HS1. You will need to give it a spin under HS2. Posted as V2.2

                              Comment

                              Working...
                              X