Kaseya Community

getting a script to reboot PC, log in as local administrator and run another agent procedure

This question is not answered

Hi Guys, appreciate your help on this. We have script (see below) that calls upon 3 Kaseya agent procedures to run on Windows 7 64 bit PC's. What we want this script to do is

1. Reboot PC and log in as local administrator (autologin)

2. install applications that requires local admin rights, turn off autologin from point 1

3. Reboot PC to login prompt for user to log in as themselves with application installed but no local admin rights.

After the first procedure (see below) the target PC reboots and the 1st procedure starts again however we want the PC to reboot and the script to then start the second and third procedures (not included below) in order to complete the task.

This script is an attempt to work around the issue we faced here http://community.kaseya.com/xsp/f/28/p/13306/65071.aspx#65071

 

  <?xml version="1.0" encoding="utf-8" ?>
- <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
- <Procedure name="AutoLogin - Part 1" treePres="3" id="1811385943">
- <Body description="This Procedure will log off the current user and logon as an admin account. This is used to install software that requires admin account.">
- <Statement description="Set the specified registry value on 64 bit systems." name="SetRegistryValue64" continueOnFail="true">
  <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon\DefaultPassword" />
  <Parameter xsi:type="StringParameter" name="Value" value="password" />
  <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
  </Statement>
- <Statement description="Set the specified registry value on 64 bit systems." name="SetRegistryValue64" continueOnFail="true">
  <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon\DefaultDomainName" />
  <Parameter xsi:type="StringParameter" name="Value" value="companyabc.local" />
  <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
  </Statement>
- <Statement description="Set the specified registry value on 64 bit systems." name="SetRegistryValue64" continueOnFail="false">
  <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon\DefaultUserName" />
  <Parameter xsi:type="StringParameter" name="Value" value="autodeploy" />
  <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
  </Statement>
- <Statement description="Delete the specified registry value on 64 bit systems" name="DeleteRegistryValue64" continueOnFail="true">
  <Parameter xsi:type="StringParameter" name="Path" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system\legalnoticecaption" />
  </Statement>
- <Statement description="Delete the specified registry value on 64 bit systems" name="DeleteRegistryValue64" continueOnFail="true">
  <Parameter xsi:type="StringParameter" name="Path" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system\legalnoticetext" />
  </Statement>
- <If description="">
- <Condition name="CheckRegistryValue64">
  <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon\AutoAdminLogon" />
  <Parameter xsi:type="EnumParameter" name="Condition" value="Equals" />
  <Parameter xsi:type="StringParameter" name="Value" value="0" />
  </Condition>
  <Then />
- <Else>
- <Statement description="Creates a Windows event log entry" name="Create Event Log Entry" continueOnFail="true">
  <Parameter xsi:type="StringParameter" name="Parameter1" value="install office" />
  <Parameter xsi:type="StringParameter" name="Parameter2" value="Information" />
  <Parameter xsi:type="StringParameter" name="Parameter3" value="Application" />
  </Statement>
- <Statement description="Display a message dialog to the user." name="SendMessage" continueOnFail="false">
  <Parameter xsi:type="StringParameter" name="Message" value="no reboot" />
  <Parameter xsi:type="BooleanParameter" name="Immediate" value="False" />
  </Statement>
  </Else>
  </If>
- <Statement description="Set the specified registry value on 64 bit systems." name="SetRegistryValue64" continueOnFail="true">
  <Parameter xsi:type="StringParameter" name="RegistryPath" value="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\winlogon\AutoAdminLogon" />
  <Parameter xsi:type="StringParameter" name="Value" value="1" />
  <Parameter xsi:type="EnumParameter" name="DataType" value="String" />
  </Statement>
  <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="true" />
  </Body>
  </Procedure>
  </ScriptExport>
All Replies
  • I do not see where you schedule the 2nd/3rd steps in this script? How do you have these scheduled?

    You should set a step in this script to schedule a procedure, and schedule the 2nd step for 15 minute delay. Set this step right before the reboot step. In your 2nd script, have it schedule the 3rd step after all steps have finished running.

  • Should try the Autologon tool from Sysinternals it would make what you are trying to do loads easier