毎日3:00にVMwareホストを再起動するようにしているが、仮想マシンを起動しっぱなしにしている場合にホストをシャットダウンしたくないのでshutdown.exeのラッパーをVB.netで作った。
Module VMwareShutdownChecker
Sub Main()
Dim cmds As String() = System.Environment.GetCommandLineArgs
Dim cmdargs As String = String.Empty
If System.Environment.GetCommandLineArgs().Count = 1 Then
End
End If
For i = 1 To System.Environment.GetCommandLineArgs().Count - 1
cmdargs = cmdargs & " " & cmds(i).ToString
Next
Dim ps As System.Diagnostics.Process() = System.Diagnostics.Process.GetProcesses()
Dim shutdownflag As Boolean = True
For Each p As System.Diagnostics.Process In ps
Try
If InStr(p.ProcessName.ToUpper, "VMWARE-VMX") > 0 Then
shutdownflag = False
Exit For
End If
Catch ex As Exception
shutdownflag = False
Exit For
End Try
Next
If shutdownflag = True Then
Dim psi As New System.Diagnostics.ProcessStartInfo()
psi.FileName = "shutdown.exe"
psi.Arguments = cmdargs
System.Diagnostics.Process.Start(psi)
End If
End Sub
End Module
コマンドラインオプションはそのままshutdown.exeにわたすので同じものを設定する。