So as explained before I'm working on a script that automatically exe at 8am. I'm almost finish but I need some help.
1. I need my msgbox to only display for 30 seconds.
2. Question: Can you timeout for 8 hours? If So how?
3. A Timeout between The shutdown and The Abort (30seconds).
4. Do You Think anything is Missing?
If anyone can help me I would Highly Thankful:
Script:
'Daily Greeting with Date and Time
SDateTime = WeekdayName(Weekday(Date)) & ", " & MonthName(Month(Date()), False) & " " & Day(Date ()) & ", " & Year(Date())
greet = "Good Morning Today is "
msgbox greet & SDateTime
'IP Information
Dim IP_Address : IP_Address = GetIP()
Dim objNet
Dim IPFound
On Error Resume Next
Set objNet = CreateObject("WScript.NetWork")
Dim strInfo
Dim strCommand
strInfo = "Computer Name = " & objNet.ComputerName
MsgBox "IP Address = " & IP_Address & vbCRLF & strInfo, 0, "WorkStation Information"
Function GetIP()
Dim ws : Set ws = CreateObject("WScript.Shell")
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
Dim ThisLine, IP
If ws.Environment("SYSTEM")("OS") = "" Then
ws.run "winipcfg /batch " & TmpFile, 0, True
Else
ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
End If
With fso.GetFile(TmpFile).OpenAsTextStream
Do While NOT .AtEndOfStream and IPFound = 0
ThisLine = .ReadLine
If InStr(ThisLine, "IPv4 Address") or inStr(Thisline, "IP Address") <> 0 Then
IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
IPFound = 1
End If
Loop
.Close
End With
If IP <> "" Then
If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
End If
GetIP = IP
fso.GetFile(TmpFile).Delete
Set fso = Nothing
Set ws = Nothing
End Function
Dim iURL
Dim objShell
iURL = "www.time.gov"
set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "chrome.exe", iURL, "", "", 1
'After 8hour Sleep
msgbox "Save All Work System Shuting Down In 2 Minutes"
Shutdown /s /t 120 /c
'Time Out for 30 seconds
Shutdown /a
Thank You In Advance
CollegeGuy215
1. I need my msgbox to only display for 30 seconds.
2. Question: Can you timeout for 8 hours? If So how?
3. A Timeout between The shutdown and The Abort (30seconds).
4. Do You Think anything is Missing?
If anyone can help me I would Highly Thankful:
Script:
'Daily Greeting with Date and Time
SDateTime = WeekdayName(Weekday(Date)) & ", " & MonthName(Month(Date()), False) & " " & Day(Date ()) & ", " & Year(Date())
greet = "Good Morning Today is "
msgbox greet & SDateTime
'IP Information
Dim IP_Address : IP_Address = GetIP()
Dim objNet
Dim IPFound
On Error Resume Next
Set objNet = CreateObject("WScript.NetWork")
Dim strInfo
Dim strCommand
strInfo = "Computer Name = " & objNet.ComputerName
MsgBox "IP Address = " & IP_Address & vbCRLF & strInfo, 0, "WorkStation Information"
Function GetIP()
Dim ws : Set ws = CreateObject("WScript.Shell")
Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
Dim TmpFile : TmpFile = fso.GetSpecialFolder(2) & "/ip.txt"
Dim ThisLine, IP
If ws.Environment("SYSTEM")("OS") = "" Then
ws.run "winipcfg /batch " & TmpFile, 0, True
Else
ws.run "%comspec% /c ipconfig > " & TmpFile, 0, True
End If
With fso.GetFile(TmpFile).OpenAsTextStream
Do While NOT .AtEndOfStream and IPFound = 0
ThisLine = .ReadLine
If InStr(ThisLine, "IPv4 Address") or inStr(Thisline, "IP Address") <> 0 Then
IP = Mid(ThisLine, InStr(ThisLine, ":") + 2)
IPFound = 1
End If
Loop
.Close
End With
If IP <> "" Then
If Asc(Right(IP, 1)) = 13 Then IP = Left(IP, Len(IP) - 1)
End If
GetIP = IP
fso.GetFile(TmpFile).Delete
Set fso = Nothing
Set ws = Nothing
End Function
Dim iURL
Dim objShell
iURL = "www.time.gov"
set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "chrome.exe", iURL, "", "", 1
'After 8hour Sleep
msgbox "Save All Work System Shuting Down In 2 Minutes"
Shutdown /s /t 120 /c
'Time Out for 30 seconds
Shutdown /a
Thank You In Advance
CollegeGuy215