UtilPowerRestart Method
Restarts the specified computer.
Namespace: DevCase.Core.IO.Devices.PowerAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
Public Shared Function Restart (
Optional computer As String = "",
Optional timeout As Integer = 0,
Optional message As String = "",
Optional mode As ShutdownMode = ShutdownMode.Wait,
Optional reason As ShutdownReason = ShutdownReason.Other,
Optional planning As ShutdownPlanning = ShutdownPlanning.Unplanned,
Optional ignoreErrors As Boolean = true
) As Boolean
Dim computer As String
Dim timeout As Integer
Dim message As String
Dim mode As ShutdownMode
Dim reason As ShutdownReason
Dim planning As ShutdownPlanning
Dim ignoreErrors As Boolean
Dim returnValue As Boolean
returnValue = UtilPower.Restart(computer,
timeout, message, mode, reason, planning,
ignoreErrors)
static member Restart :
?computer : string *
?timeout : int *
?message : string *
?mode : ShutdownMode *
?reason : ShutdownReason *
?planning : ShutdownPlanning *
?ignoreErrors : bool
(* Defaults:
let _computer = defaultArg computer ""
let _timeout = defaultArg timeout 0
let _message = defaultArg message ""
let _mode = defaultArg mode ShutdownMode.Wait
let _reason = defaultArg reason ShutdownReason.Other
let _planning = defaultArg planning ShutdownPlanning.Unplanned
let _ignoreErrors = defaultArg ignoreErrors true
*)
-> bool
No code example is currently available or this language may not be supported.
- computer String (Optional)
-
The name of the computer to restart.
If the value of this parameter is an empty string, the local computer is shut down.
This parameter can be an addres, for example: 127.0.0.1
- timeout Int32 (Optional)
-
The number of seconds to wait before restarting the computer.
If the value of this parameter is zero, the computer is restarted immediately.
This value is limited to MaxShutdownTimeout.
- message String (Optional)
-
The message to be displayed in the interactive restart dialog box.
- mode ShutdownMode (Optional)
-
Indicates whether to force the restart.
- reason ShutdownReason (Optional)
-
The reason for initiating the restart.
By default, it is also an 'unplanned' restart.
If this parameter is zero,
the default is an undefined restart that is logged as "No title for this reason could be found".
- planning ShutdownPlanning (Optional)
-
Indicates whether it's a planned or unplanned restart operation.
- ignoreErrors Boolean (Optional)
-
If , a Win32Exception exception will be thrown if error found.
Boolean if the restart operation is initiated correctlly,
otherwise.
This is a code example that tries to restart the operating system, then abort the restart operation.
No code example is currently available or this language may not be supported.
' Restart the current computer in 60 seconds and wait for applications to close.
' Specify that the restart operation is planned because a consecuence of an installation.
Dim success As Boolean =
PowerUtil.Restart(Nothing, 60, "System is gonna be restarted quickly, go save all your data now...!",
ShutdownMode.Wait,
ShutdownReason.MajorOperatingSystem Or
ShutdownReason.MinorInstallation,
ShutdownPlanning.Planned)
Console.WriteLine(String.Format("Restart operation initiated successfully?: {0}", CStr(success)))
' Abort the current operation.
If success Then
Dim isAborted As Boolean = Abort(computer:=Nothing, ignoreErrors:=False)
Console.WriteLine(String.Format("Restart operation aborted successfully?: {0}", CStr(isAborted)))
Else
Console.WriteLine("There is any restart operation to abort.")
End If
If MessageBox.Show("Want to proceed inmediately with a shutdown that cannot be aborted ?", "",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
' Shutdown the current computer instantlly and force applications to close.
' ( When timeout is '0' the operation can't be aborted )
PowerUtil.Shutdown(Nothing, 0, Nothing, ShutdownMode.ForceSelf)
' LogOffs the current user.
PowerUtil.LogOff(LogOffMode.Wait)
End If
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
ArgumentException
|
Timeout should be zero or greater than zero.;timeout
|
Win32Exception
|
|