Option Explicit
' arnelgp
Public Enum PowerOffOptions
poweroffShutdown = 1
powerOffRestart = 2
powerOffLogOff = 3
poweroffHybernate = 4
End Enum
Public Function VBA_PowerOff(PowerOffOption As PowerOffOptions)
Dim strCommand As String
Dim strFile As String
strFile = Environ("temp") & "\zzCmd.bat"
strCommand = "@shutdown.exe "
Select Case PowerOffOption
Case Is = PowerOffOptions.poweroffShutdown
strCommand = strCommand & "/s /f /t 0"
Case Is = PowerOffOptions.powerOffRestart
strCommand = strCommand & "/r /f"
Case Is = PowerOffOptions.powerOffLogOff
strCommand = strCommand & "/l /f"
Case Is = PowerOffOptions.poweroffHybernate
strCommand = strCommand & "/h /f"
End Select
subSaveStream strFile, strCommand
Call Shell(strFile)
End Function
Public Sub subSaveStream(ByVal sFileName As String, ByVal sText As String)
Dim fso As Object
Dim txtStream As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtStream = fso.CreateTextFile(sFileName, True)
With txtStream
.Write sText
.Close
End With
Set txtStream = Nothing
Set fso = Nothing
sFileName = ""
sText = ""
End Sub
VBA kodu ile pc yi nasıl tekrar başlatabiliriz
@benbendedeilem
Son Düzenleme: 29/05/2020, 11:14, Düzenleyen: accessman.