Kaseya Community

Reboot - Ask No Nag

This question has suggested answer(s)

I am trying to create a procedure that does the following

========================================

Checks to see if user is logged on. 

If user logged on Ask if can reboot

Else reboot

If user response is Yes

Reboot

If user does not respond in 15 mins 

reboot

If user says No wait 15 mins and repeat procedure

==========================================

I am having a hard time with the repeat / no response. Any help would be greatly appreciated

 

Thanks

 

Jesse 

All Replies
  • for the wait 15 minutes are you just rescheduling the same script to run in 15 minutes time.

  • No it  calls script 2

    Here is what I have...base off the samples

    1

    =======================================================================================================

    <?xml version="1.0" encoding="utf-8"?>

    <ScriptExport xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns="www.kaseya.com/.../Scripting">

     <Procedure name="Reboot - Ask Nag" treePres="3">

       <Body description="">

         <If description="">

           <Condition name="UserIsLoggedIn">

             <Parameter xsi:type="StringParameter" name="UserName" value="" />

           </Condition>

           <Then>

             <If description="">

               <Condition name="UserResponseIsYes">

                 <Parameter xsi:type="StringParameter" name="Message" value="+++YES:Reboot Now++++++NO:Continue Working+++The system administrator needs to Reboot your computer. Reboot now?" />

                 <Parameter xsi:type="IntegerParameter" name="Timeout" value="1" />

               </Condition>

               <Then>

                 <Statement description="Reboot the machine this procedure is running on. - WARNING: Reboot must be the last step in a procedure or the procedure will start again from step 1 after the reboot." name="Reboot" continueOnFail="false" osType="Windows" />

               </Then>

               <Else>

                 <Statement description="Execute the specified procedure. - NOTE: this procedure does not complete until the called procedure completes." name="ExecuteScript" continueOnFail="true" osType="Windows">

                   <Parameter xsi:type="StringParameter" name="ScriptID" value="1725752992" />

                   <Parameter xsi:type="StringParameter" name="FolderName" value="myProcedures - jesseh.Reboot.Reboot - Ask Nag" />

                   <Parameter xsi:type="StringParameter" name="ScriptName" value="Reboot - Ask Nag 2" />

                   <Parameter xsi:type="StringParameter" name="TimeDelay" value="" />

                   <Parameter xsi:type="EnumParameter" name="TimeUnit" value="Immediate" />

                 </Statement>

               </Else>

             </If>

           </Then>

           <Else>

             <Statement description="Reboot the machine this procedure is running on. - WARNING: Reboot must be the last step in a procedure or the procedure will start again from step 1 after the reboot." name="Reboot" continueOnFail="false" osType="Windows" />

           </Else>

         </If>

       </Body>

     </Procedure>

    </ScriptExport>

    ===============================================================================================

    2

    ===============================================================================================

    <?xml version="1.0" encoding="utf-8"?>

    <ScriptExport xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns="www.kaseya.com/.../Scripting">

     <Procedure name="Reboot - Ask Nag 2" treePres="3">

       <Body description="">

         <If description="">

           <Condition name="UserIsLoggedIn">

             <Parameter xsi:type="StringParameter" name="UserName" value="" />

           </Condition>

           <Then>

             <If description="">

               <Condition name="UserResponseIsYes">

                 <Parameter xsi:type="StringParameter" name="Message" value="+++YES:Reboot Now++++++NO:Continue Working+++The system administrator needs to Reboot your computer. Reboot now?" />

                 <Parameter xsi:type="IntegerParameter" name="Timeout" value="1" />

               </Condition>

               <Then>

                 <Statement description="Reboot the machine this procedure is running on. - WARNING: Reboot must be the last step in a procedure or the procedure will start again from step 1 after the reboot." name="Reboot" continueOnFail="false" osType="Windows" />

               </Then>

               <Else>

                 <Statement description="Schedule a procedure to run on a specified machine." name="ScheduleScript" continueOnFail="true" osType="Windows">

                   <Parameter xsi:type="StringParameter" name="ScriptName" value="1839328968" />

                   <Parameter xsi:type="StringParameter" name="TimeDelay" value="2" />

                   <Parameter xsi:type="StringParameter" name="MachineID" value="" />

                 </Statement>

               </Else>

             </If>

           </Then>

           <Else>

             <Statement description="Reboot the machine this procedure is running on. - WARNING: Reboot must be the last step in a procedure or the procedure will start again from step 1 after the reboot." name="Reboot" continueOnFail="false" osType="Windows" />

           </Else>

         </If>

       </Body>

     </Procedure>

    </ScriptExport>

    ====================================================================================================

  • Hi Jesseh

    I swapped your code around a little and made it one script. If they say continue anyway it classes it as a yes since you want the else to reboot.

     

    You will need to repoint the schedule script back at this script.

    Sorry im not sure how to enter code

     


    <?xml version="1.0" encoding="utf-8"?>

    <ScriptExport xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns="www.kaseya.com/.../Scripting">

     <Procedure name="Reboot - Ask Nag" treePres="3">

       <Body description="Script will &#xD;&#xA;&#xD;&#xA;Checks to see if user is logged on. &#xD;&#xA;     If user logged on Ask if can - reboot&#xD;&#xA;         If user response is Continue Working - wait 15 mins and repeat procedure&#xD;&#xA;Else reboot">

         <If description="">

           <Condition name="UserIsLoggedIn">

             <Parameter xsi:type="StringParameter" name="UserName" value="" />

           </Condition>

           <Then>

             <If description="">

               <Condition name="UserResponseIsYes">

                 <Parameter xsi:type="StringParameter" name="Message" value="+++YES:Continue Working++++++NO:Reboot Now+++The system administrator needs to Reboot your computer. Reboot now?" />

                 <Parameter xsi:type="IntegerParameter" name="Timeout" value="15" />

               </Condition>

               <Then>

                 <Statement description="Schedule a procedure to run on a specified machine." name="ScheduleScript" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="ScriptName" value="224984307" />

                   <Parameter xsi:type="StringParameter" name="TimeDelay" value="15" />

                   <Parameter xsi:type="StringParameter" name="MachineID" value="#vAgentConfiguration.MachName#" />

                 </Statement>

               </Then>

               <Else>

                 <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="Command" value="Shutdown -r -f -t 1 " />

                   <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />

                   <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />

                 </Statement>

               </Else>

             </If>

           </Then>

           <Else>

             <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false">

               <Parameter xsi:type="StringParameter" name="Command" value="Shutdown -r -f -t 1 " />

               <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />

               <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />

             </Statement>

           </Else>

         </If>

       </Body>

     </Procedure>

    </ScriptExport>

     


     

     



    [edited by: Lingario at 12:04 PM (GMT -8) on 1-25-2011] Tried to edit code
  • Here is a single script I put together. This will ask user if it is OK to reboot. If the user is not logged in it will automatically reboot. If the user chooses to continue working, it will prompt them again in 30 minutes to reboot. The script will abort if the user manually reboots.

    <?xml version="1.0" encoding="utf-8"?>

    <ScriptExport xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns="www.kaseya.com/.../Scripting">

     <Procedure name="Reboot-Nag-Backup" treePres="3" id="461993116" folderId="63114784135113187338671254">

       <Body description="This will ask user if it is OK to reboot. If the user is not logged in it will automatically reboot. If the user chooses to continue working, it will prompt them again in 30 minutes to reboot. The script will abort if the user manually reboots.
    &#xA;&#xA;-wb Mar 06, 2012">

         <If description="Check if user is logged in.">

           <Condition name="UserIsLoggedIn">

             <Parameter xsi:type="StringParameter" name="UserName" value="" />

           </Condition>

           <Then>

             <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false" osType="Windows">

               <Parameter xsi:type="EnumParameter" name="VariableType" value="AgentInstallDrive" />

               <Parameter xsi:type="StringParameter" name="SourceContent" value="" />

               <Parameter xsi:type="StringParameter" name="VariableName" value="agentDrv" />

             </Statement>

             <If description="This is used for a default message if on does not exist from another procedure.">

               <Condition name="TestFile">

                 <Parameter xsi:type="StringParameter" name="Path" value="#agentDrv#temp\message.txt" />

                 <Parameter xsi:type="EnumParameter" name="Condition" value="NotExists" />

                 <Parameter xsi:type="StringParameter" name="Value" value="" />

               </Condition>

               <Then>

                 <Statement description="Write the default message to a text to file" name="Write text to file" continueOnFail="false" osType="Windows">

                   <Parameter xsi:type="StringParameter" name="Parameter1" value="The system administrator needs to Reboot your computer. If you Continue Working, you will be reminded in 30 minutes." />

                   <Parameter xsi:type="StringParameter" name="Parameter2" value="#agentDrv#temp\message.txt" />

                   <Parameter xsi:type="StringParameter" name="Parameter3" value="false" />

                 </Statement>

               </Then>

             </If>

             <If description="">

               <Condition name="CheckRegistryValue">

                 <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Your-Location\LastReboot1" />

                 <Parameter xsi:type="EnumParameter" name="Condition" value="NotExists" />

                 <Parameter xsi:type="StringParameter" name="Value" value="" />

               </Condition>

               <Then>

                 <Statement description="Set the specified registry value - Regedit displays keys as folders and values as documents." name="SetRegistryValue" continueOnFail="false" osType="Windows">

                   <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Your-Location\LastReboot1" />

                   <Parameter xsi:type="StringParameter" name="Value" value="#vAgentConfiguration.lastReboot#" />

                   <Parameter xsi:type="EnumParameter" name="DataType" value="String" />

                 </Statement>

               </Then>

             </If>

             <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false" osType="Windows">

               <Parameter xsi:type="EnumParameter" name="VariableType" value="FileContent" />

               <Parameter xsi:type="StringParameter" name="SourceContent" value="#agentDrv#temp\message.txt" />

               <Parameter xsi:type="StringParameter" name="VariableName" value="mess" />

             </Statement>

             <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false" osType="Windows">

               <Parameter xsi:type="EnumParameter" name="VariableType" value="RegistryValue" />

               <Parameter xsi:type="StringParameter" name="SourceContent" value="HKEY_LOCAL_MACHINE\SOFTWARE\Your-Location\LastReboot1" />

               <Parameter xsi:type="StringParameter" name="VariableName" value="lastreboot1" />

             </Statement>

             <If description="Compare the reboot times. If the lastreboot registry entries differs from the vAgentConfiguration.lastReboot then ask user for response, otherwise machine has already been rebooted and delete entries to abort.">

               <Condition name="CheckVariable">

                 <Parameter xsi:type="StringParameter" name="VariableName" value="#lastreboot1#" />

                 <Parameter xsi:type="EnumParameter" name="Condition" value="Equals" />

                 <Parameter xsi:type="StringParameter" name="Value" value="#vAgentConfiguration.lastReboot#" />

               </Condition>

               <Then>

                 <If description="Ask User for Response">

                   <Condition name="UserResponseIsYes">

                     <Parameter xsi:type="StringParameter" name="Message" value="+++YES:Reboot Now++++++NO:Continue Working+++#mess#" />

                     <Parameter xsi:type="IntegerParameter" name="Timeout" value="10" />

                   </Condition>

                   <Then>

                     <Statement description="Delete the specified file - full path to the filename required." name="DeleteFile" continueOnFail="false" osType="Windows">

                       <Parameter xsi:type="StringParameter" name="Path" value="#agentDrv#temp\message.txt" />

                     </Statement>

                     <Statement description="Delete the specified registry value - Regedit displays keys as folders and values as documents." name="DeleteRegistryValue" continueOnFail="false">

                       <Parameter xsi:type="StringParameter" name="Path" value="HKEY_LOCAL_MACHINE\SOFTWARE\Your-Location\LastReboot1" />

                     </Statement>

                     <Statement description="Execute the given command as if it were typed in at a command prompt." name="ExecuteShellCommand" continueOnFail="false" osType="Windows">

                       <Parameter xsi:type="StringParameter" name="Command" value="shutdown -r -t 10" />

                       <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />

                       <Parameter xsi:type="BooleanParameter" name="Is64Bit" value="False" />

                     </Statement>

                   </Then>

                   <Else>

                     <Statement description="Call Itself in 30 minutes" name="ExecuteScript" continueOnFail="false" osType="Windows">

                       <Parameter xsi:type="StringParameter" name="ScriptID" value="1358217950" />

                       <Parameter xsi:type="StringParameter" name="ScriptName" value="Reboot-Nag-PC" />

                       <Parameter xsi:type="StringParameter" name="TimeDelay" value="30" />

                       <Parameter xsi:type="EnumParameter" name="TimeUnit" value="Minutes" />

                     </Statement>

                   </Else>

                 </If>

               </Then>

               <Else>

                 <Statement description="Delete the specified registry value - Regedit displays keys as folders and values as documents." name="DeleteRegistryValue" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="Path" value="HKEY_LOCAL_MACHINE\SOFTWARE\Your-Location\LastReboot1" />

                 </Statement>

                 <Statement description="Delete the specified file - full path to the filename required." name="DeleteFile" continueOnFail="false" osType="Windows">

                   <Parameter xsi:type="StringParameter" name="Path" value="#agentDrv#temp\message.txt" />

                 </Statement>

               </Else>

             </If>

           </Then>

           <Else>

             <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="false" osType="Windows">

               <Parameter xsi:type="EnumParameter" name="VariableType" value="AgentInstallDrive" />

               <Parameter xsi:type="StringParameter" name="SourceContent" value="" />

               <Parameter xsi:type="StringParameter" name="VariableName" value="agentDrv" />

             </Statement>

             <If description="">

               <Condition name="TestFile">

                 <Parameter xsi:type="StringParameter" name="Path" value="#agentDrv#temp\message.txt" />

                 <Parameter xsi:type="EnumParameter" name="Condition" value="Exists" />

                 <Parameter xsi:type="StringParameter" name="Value" value="" />

               </Condition>

               <Then>

                 <Statement description="Delete the specified file - full path to the filename required." name="DeleteFile" continueOnFail="false" osType="Windows">

                   <Parameter xsi:type="StringParameter" name="Path" value="#agentDrv#temp\message.txt" />

                 </Statement>

               </Then>

             </If>

             <If description="">

               <Condition name="CheckRegistryValue">

                 <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Your-Location\LastReboot1" />

                 <Parameter xsi:type="EnumParameter" name="Condition" value="Exists" />

                 <Parameter xsi:type="StringParameter" name="Value" value="" />

               </Condition>

               <Then>

                 <Statement description="Delete the specified registry value - Regedit displays keys as folders and values as documents." name="DeleteRegistryValue" continueOnFail="false">

                   <Parameter xsi:type="StringParameter" name="Path" value="HKEY_LOCAL_MACHINE\SOFTWARE\Your-Location\LastReboot1" />

                 </Statement>

               </Then>

             </If>

             <Statement description="Reboot the machine this procedure is running on. - WARNING: Reboot must be the last step in a procedure or the procedure will start again from step 1 after the reboot." name="Reboot" continueOnFail="false" />

           </Else>

         </If>

       </Body>

     </Procedure>

    </ScriptExport>



    [edited by: William Banes at 1:54 PM (GMT -8) on 3-6-2012] Updated Notes