Jump to content

[help] How to shut down system from dos with countdown


Recommended Posts

Here is a up dated script

Save As MkRebootHta_V1.vbs

Dim Act  : Set Act = CreateObject("Wscript.Shell")
Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Desk : Desk = Act.SpecialFolders("Desktop")
Dim HTA : HTA = Desk & "\ReBoot.Hta"
Dim VBS : VBS = Act.ExpandEnvironmentStrings("%SystemDrive%\MkRebootHta_V1.Vbs")
'/-> Set The Reboot Time
Dim User
User = InputBox("Type in the amount of seconds to set the Reboot Time for" &_
" the ReBoot.Hta!" & vbCrLf & "If nothing is inputted then it will use 30 " &_
"seconds as the default ReBoot time","Set Time",,5500,4800)
'/-> Defualt Time
If User = "" Then User = 30 End If
'/-> Make The HTA
Dim Ts : Set Ts = Fso.CreateTextFile(HTA)
Ts.WriteLine " <Head><HTML><Title>Re Booting " & Act.ExpandEnvironmentStrings("%ComputerName%") & "</Title>"
Ts.WriteLine " <HTA:APPLICATION"
Ts.WriteLine " BORDER = ""thin"" SysMenu = ""NO"""
Ts.WriteLine " SCROLL = ""No"" SHOWINTASKBAR = ""No"""
Ts.WriteLine " CAPTION = ""Yes"">"
Ts.WriteLine " <STYLE type=""text/css"">"
Ts.WriteLine " BODY.Style1"
Ts.WriteLine " {font:8pt Verdana; color:#000080; font-weight:bold;"
Ts.WriteLine " filter:progid:DXImageTransform.Microsoft.Gradient"
Ts.WriteLine " (GradientType=0,StartColorStr='#E2E2E2',EndColorStr='#5a6066');"
Ts.WriteLine " padding-top:1; padding-bottom:1; Text-Align:Center;}"
Ts.WriteLine " TD.Style1"
Ts.WriteLine " {font:8.25pt Verdana; color:#008000; font-weight: Bold-Italic;}"
Ts.WriteLine " TD.Style2"
Ts.WriteLine " {font:8.25pt Verdana; color:#000080; font-weight: Bold-Italic;}"
Ts.WriteLine " </STYLE>"
Ts.WriteLine " <script Language='VBSCRIPT'> window.resizeTo 355,150 : window.moveTo 170,195"
Ts.WriteLine " Dim Act, CD,Cnt, CName, Dnt, Fso, HTA, Ln1, TD1, TD2, Uname"
Ts.WriteLine " '/-> Set The Amount Of Time With Cnt"
Ts.WriteLine " Cnt = """ & User + 1 & """ : Dnt = 1"
Ts.WriteLine " Ln1 = "" "" & Chr(187) & "" """
Ts.WriteLine " TD1 = ""<TD Style='font:8.75pt Verdana; color:Gold; font-weight: Bold'"" &_"
Ts.WriteLine " ""Height='14' Width='45' Align='Center'>"""
Ts.WriteLine " Set Act = CreateObject(""Wscript.Shell"")"
Ts.WriteLine " Set Fso = CreateObject(""Scripting.FileSystemObject"")"
Ts.WriteLine " Cname = Act.ExpandEnvironmentStrings(""%ComputerName%"")"
Ts.WriteLine " Uname = Act.ExpandEnvironmentStrings(""%UserName%"")"
Ts.WriteLine " HTA = Act.CurrentDirectory & ""\ReBoot.Hta"""
Ts.WriteLine " '/->"
Ts.WriteLine " Function Window_onload"
Ts.WriteLine " idTimer = window.setTimeout(""Counter"", 1000, ""VBScript"")"
Ts.WriteLine " txt1.innerHTML = UName & ""<Table><TD Style='font:8.25pt Verdana;'>"" &_"
Ts.WriteLine " ""Save or Close any Open Programs or Files</TD></Table>"""
Ts.WriteLine " End Function"
Ts.WriteLine " Function Counter"
Ts.WriteLine " Do"
Ts.WriteLine " Dnt = Dnt -1 : Cnt = Cnt - 1"
Ts.WriteLine " txt2.innerHTML = ""<Table><TD Style='font:8.25pt Verdana;'>Restarting "" &_"
Ts.WriteLine " Ln1 & CName & "" In </TD>"" & TD1 & Ln1 & Cnt & "" </TD>"" &_"
Ts.WriteLine " ""<TD Style='font:8.25pt Verdana;'>Seconds</TD></Table>"""
Ts.WriteLine " loop Until Dnt = 0"
Ts.WriteLine " Dnt = 1"
Ts.WriteLine " If Cnt = 0 Then : HtaExit : End if"
Ts.WriteLine " Window_onload"
Ts.WriteLine " End Function"
Ts.WriteLine " '/-> Reboot Computer, Delete The Hta, Close The Window"
Ts.WriteLine " Function HtaExit"
Ts.WriteLine " Act.Run(""shutdown.exe -r -f -t 00""),0,true"
Ts.WriteLine " Fso.DeleteFile(HTA) : window.close"
Ts.WriteLine " End Function"
Ts.WriteLine " </SCRIPT><Body Class='Style1'>"
Ts.WriteLine "<!-- Text1 Display -->"
Ts.WriteLine " <Table><TD Class='Style2' Height='14' Align='Center'><Span ID='txt1'></Span></TD></Table>"
Ts.WriteLine "<!-- Text2 Display -->"
Ts.WriteLine "<Table><TD Class='Style1' Height='14'><Span ID='txt2'></Span></TD></Table></Body>"
Ts.Close
'/-> Message Box Shows The Location Of The HTA
Act.Popup "The ReBoot.Hta is Located Here" & vbCrLf & Desk, 15, "Finished", 0 + 32 + 0
'/-> Delete The VBS File After It Been Extracted
If Fso.FileExists(VBS) Then Fso.DeleteFile(VBS) End If

MkRebootHta_V1.exe

Edited by gunsmokingman
Link to comment
Share on other sites


Using a batch file and cheating at the same time, try this!

It is just a batch file, I places it inside a zip file just in case of forum formatting errors. When you read it you will see why!

Would you or anyone else care to explain what does ~tmp.exe do? :rolleyes:

Link to comment
Share on other sites

Would you or anyone else care to explain what does ~tmp.exe do? :rolleyes:

just briefly looked over the code, but if i have this right (which i probably do haha) i'll explain it.

in short.. it's just a coutdown script

in long..

the "jibberish" thats being echoed gets written to the file ~tmp.com then gets executed and the output is dumped to the file ~tmp.exe (thats the real executable, all it does is counts down by 1 second intervals with the help of the tmp.vbs script). once the countdown has been reached "shutdown.exe -r -f -t 00" gets ran which tells the comp to shutdown immediatly.

Link to comment
Share on other sites

Thanks for your help. Pls bear with me...

I still don't understand what the "jibberish" code means and what the exe does.

I can see the for in do loop does the countdown from 180 but what exactly does ~tmp.exe do inside the loop?

Link to comment
Share on other sites

@ Takeshi

That "jibberish" code is simply some other symbols relevant to those characters appearing on your keyboard.

Surprisingly, that "jibberish" code is meant to write the following into the COM file:

MZ`.............`.......@...............................................!..L.!Nice to meet somebody who is still using DOS,..but his program requires Win32...$.PE..L...Py.6..................................... ....@.......................... ..................................................<.................................................................................................

...................text..

............................. ...................................................................l.......................

....d...........X...................z...........................USER32.dll..l.........

MessageBoxA.KERNEL32.dll........................ExitProcess...GetStdHandle....WriteFile...GetCommand

LineA

..........F<.t.<$u...

........................F<.t.. ,Wy..'......`.x.@.1.....@.u.j.....@....@.j.h..@.j.hx.@.P....@..

.a.u.j.hy.@.hy.@.j.....@.j.....@..=..@.....u...write error............`....@.H@.8.t..8 u.@>.D$.a.....P....@...........................................................................

@ gunsmokingman

Nice GUI.

Link to comment
Share on other sites

That "jibberish" code is simply some other symbols relevant to those characters appearing on your keyboard.

Surprisingly, that "jibberish" code is meant to write the following into the COM file:

Thanks mazin, appreciated your time and patience!

:thumbup:thumbup

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...