Author Topic: System.Restart force:<true|false>  (Read 1445 times)

0 Members and 1 Guest are viewing this topic.

marcusvdt

  • Sr. Member
  • ****
  • Posts: 152
  • Karma: 6
  • Researching
    • View Profile
System.Restart force:<true|false>
« on: August 19, 2015, 12:29:41 PM »
If I am requesting tasks to the computer from my bed and I notice something is wrong with Windows, I could want to perform a system restart before I either stand up and do the actual tasks manually or get to the computer to check what is wrong with it.
The suggestion for the parameter "force" is to allow the user to choose from a forced restart where all the programs will be killed, etc or a normal restart, where windows will ask about programs still running, etc.
For my own need, I would only use the forced restart, but for people who are actually in front of the computer and use VC to facilitate their work, then the non forced restart should be an option. They could have for example a restart macro with a sequence oc actions where they perform the window.close in some programs and after that perform the normal restart. If windows still asks for running programs, then a manual check could be required before restarting.

Hope it is possible and makes sense.
Thanks.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: System.Restart force:<true|false>
« Reply #1 on: August 19, 2015, 12:37:06 PM »
I don't know if this can be done in .Net code but it should be easy to implement using Launch.

http://blog-archive.josephcs.com/how-to-force-shutdown-or-restart/#main_content

marcusvdt

  • Sr. Member
  • ****
  • Posts: 152
  • Karma: 6
  • Researching
    • View Profile
Re: System.Restart force:<true|false>
« Reply #2 on: August 19, 2015, 04:23:40 PM »
Oh ok, thanks! I suggested a restart action because you already have a shutdown action so I though it was possible and perhaps more elegant. But you are right, the launch action is working perfectly.

Here it is so anybody who finds this thread later can eventually use it.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.7-->
<commandGroup open="True" name="System/Vox Restart-EN" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="716" name="Abort Restart" enabled="true" alwaysOn="True" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Launch.Capture</cmdType>
      <params>
        <param>c:\windows\system32\shutdown.exe</param>
        <param> /a</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>File.AppendLine</cmdType>
      <params>
        <param>{Path.VC}\restarts.log</param>
        <param>{ShortDate}-{LongTime}-{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Restart aborted. Thanks.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>cancel,abort</phrase>
    <phrase optional="true">the</phrase>
    <phrase optional="true">computer,pc,system</phrase>
    <phrase>restart</phrase>
  </command>
  <command id="717" name="Restart PC" enabled="true" alwaysOn="True" confirm="True" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Launch.Capture</cmdType>
      <params>
        <param>c:\windows\system32\shutdown.exe</param>
        <param> /r /f /d p:0:0</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>File.AppendLine</cmdType>
      <params>
        <param>{Path.VC}\restarts.log</param>
        <param>{ShortDate}-{LongTime}-{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>I'm gonna restart myself in less than 1 minute. Say abort restart if you want to cancel.</param>
        <param>60000</param>
        <param>1</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Restarting computer in less than 1 minute. Say ABORT RESTART if you want to cancel.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>restart</phrase>
    <phrase optional="true">the</phrase>
    <phrase>computer,pc,system</phrase>
  </command>
  <command id="695" name="Restart Vox Commando" enabled="true" alwaysOn="True" confirm="True" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.RestartFull</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.SpeakSync</cmdType>
      <params>
        <param>Restarting Vox Commando.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Restart Vox Commando,Restart Vox</phrase>
  </command>
</commandGroup>
« Last Edit: August 19, 2015, 04:31:33 PM by marcusvdt »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: System.Restart force:<true|false>
« Reply #3 on: August 19, 2015, 08:01:49 PM »
Thanks.  :bignod