Hello,

Do you know how to write a little code for a simple second
countdown ?

Example : show a msgbox that countsdown 30 seconds and then closes
that msgbox.

Kind regards

Re: Countdown by S

S
Wed Jun 20 09:33:56 CDT 2007

cant be done.
youll need to create an IE window and do it that way. search the group.
there are thousands of examples



"chapeau_melon" <tomagneessens@hotmail.com> wrote in message
news:1182348308.018465.111850@u2g2000hsc.googlegroups.com...
> Hello,
>
> Do you know how to write a little code for a simple second
> countdown ?
>
> Example : show a msgbox that countsdown 30 seconds and then closes
> that msgbox.
>
> Kind regards
>


Re: Countdown by itsmillertime4u

itsmillertime4u
Wed Jun 20 09:41:48 CDT 2007

This was just discussed two days ago see here:
http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/ceccf160433df8f6?hl=en


RE: Countdown by RemS

RemS
Wed Jun 20 19:17:42 CDT 2007

"chapeau_melon" wrote:
> Hello,
>
> Do you know how to write a little code for a simple second
> countdown ?
>
> Example : show a msgbox that countsdown 30 seconds and then closes
> that msgbox.
>
> Kind regards
>

You can simulate something like this with a: objShell.Popup

Use 2 scripts.
One script(B) is copying the other script(A) to a target computer.

Script(B) copies the vbs-file, and at the same time it
also creates a scheduledJob on the target computer.
This scheduledJob runs script(A) Interactively as the SystemAccount .

The scheduledJob starts Script(A) locally on the target computer.

Script(A) starts a countdown using allways-on-top "popups" for about 50
seconds.
Then at zero, it deletes it-self, and Power-Down the computer.

this is script(A):

Set objShell = WScript.CreateObject("WScript.Shell")
i = 10
Do Until i = 0
chk = " [ "& i &" ] "
BtnCode = objShell.Popup("A Shutdown is planned" _
& vbNewLine & vbNewLine & chk _
& vbNewLine, 5, chk & "Counting down", 0+48+4096)
i = i -1
Wscript.Sleep 0
Loop

Set objFSO = CreateObject("Scripting.FileSystemObject")

' objFSO.DeleteFile(WScript.ScriptFullName) 'disabled
' ShutDown() 'disabled

msgBox "Bye bye..."
wscript.quit

Sub ShutDown()
'http://www.motobit.com/tips/detpg_wmi-windows-system-shutdown
Dim Connection, WQL, SystemClass, System
'Get connection To local wmi
Set Connection = GetObject("winmgmts:root\cimv2")
'Get Win32_OperatingSystem objects - only one object In collection
WQL = "Select Name From Win32_OperatingSystem"
Set SystemClass = Connection.ExecQuery(WQL)
'Get one system object
'I think there is no way To get the object using URL?
For Each System In SystemClass
System.Win32ShutDown (8 + 4)
Next
End Sub

-----------------------------------------------------
three values for you to set the total delay:
i = counting down from
5 = popup visible (in seconds)
0 = popup not visible (sleep in miliseconds)

Note that for testing reasons I disabled the two lines that are
doing the 'self-deletion' and the 'PowerOff'. You have to activate these two
lines your self.


This is script(B):

strComputer = "computername" '(name of target computer)
strTaskScript = "shutdown.vbs" '(the script that will run
' locally on the remote computer)

'Copy File
strSourcePath = "c:\scripts" '(local path)
strDestinationPath = "c:" '(local path, the folder MUST exist)

'On the target Computer:
stRunJob = "wscript.exe "& strDestinationPath &"\"& strTaskScript
strWaitMinutes = 2 '(2 is the minimum for the scheduledJob to start)


'___
'// do file transfer
strDestinationPath2 = Replace(strDestinationPath, ":","$")
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile strSourcePath &"\"& strTaskScript, _
"\\"& strComputer &"\"& strDestinationPath2 &"\", OverWriteExisting

'___
'// dlsBIAS, according to the timezone on your! computer

Set objSWbemServices = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\.\root\cimv2")

Set colComputer = objSWbemServices.ExecQuery _
("SELECT CurrentTimeZone FROM Win32_ComputerSystem")
For Each objComputer in colComputer
BiasGMT = objComputer.CurrentTimeZone
Exit For
Next
Set objSWbemServices = Nothing
If Int(instr(Cstr(BiasGMT),"-"))=1 Then a="-" Else a="+"
BiasGMT = a & Right(1000 + Abs(BiasGMT),3)
'___
'// determine the CURRENT_TIME from the target! computer

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LocalTime")

For Each objItem in colItems
strtTime = (objItem.Hour*100) + (objItem.Minute + strWaitMinutes)
Exit For
Next
'___
'// create a new SCHEDULEDJOB on the target computer
' http://msdn2.microsoft.com/en-us/library/aa394601.aspx

Set objService = GetObject("winmgmts:\\" & strComputer)
Set objNewJob = objService.Get("Win32_ScheduledJob")

sScheduled = "********" & Right(10000 + strtTime,4) _
& "00.000000" & BiasGMT

errJobCreated = objNewJob.Create _
(stRunJob, sScheduled, , , , True, JobID)

If Err.Number = 0 Then
Wscript.Echo "New Job ID: " & JobID
Else
Wscript.Echo "An error occurred: " & errJobCreated
End If

-----------------------------------------------------
I will suggest to test script(A) first, as it is here.

\RemS