[Script] HTA para auto desligamento das estações de trabalho do domínio

Scripts diversos para automatizar tarefas em servidores ou auxilio com tarefas administrativas.
Avatar do usuário
marceloleaes
Administrator
Administrator
Mensagens: 1516
Registrado em: 10 Jun 2013 12:45
Localização: Novo Hamburgo
Idade: 41
Contato:
Status: Offline

[Script] HTA para auto desligamento das estações de trabalho do domínio

Mensagem por marceloleaes »

Buenas

Segue um script que eu estava trabalhando a algum tempo e hoje consegui finalizar. Ao executar ele irá exibir uma janela em HTA e iniciar um timer para o auto desligamento da estação de trabalho do usuário, caso não haja nenhuma interação desligará no tempo de 5 minutos, caso o usuário precise ficar mais um tempo na estação trabalhando poderá escolher + 15,30,60 minutos para efetuar suas tarefas. Após a estação desligará  ;)

Segue código ( salvar com a extensão .hta ), bom proveito !

Código: Selecionar todos

<html>
<title>Auto-desligamento</title>
<HTA:APPLICATION
APPLICATIONNAME      = "Auto-desligamento E-tab"
ID                   = "Auto-desligamento E-tab"
BORDERSTYLE            = "Normal"
CAPTION                = "Yes"
CONTEXTMENU            = "No"
INNERBORDER            = "Yes"
MAXIMIZEBUTTON         = "No"
MINIMIZEBUTTON         = "No"
NAVIGABLE              = "No"
SCROLL                 = "No"
SCROLLFLAT             = "Yes"
SELECTION              = "No"
SHOWINTASKBAR          = "No"
SINGLEINSTANCE         = "Yes"
SYSMENU                = "No"
> 
<head>
<STYLE>
html, body {
    font-family: Verdana,Arial,Helvetica,sans-serif;
    font-size: 87%;
    line-height: 1.5em;
    margin: 0;
    padding: 0;
}
#top_body {
    clear: both;
    margin: 20px 0 0;
    text-align: center;
}
#top_body p {
    font-style: italic;
    margin: 20px 0 0;
}
#countdown {
    color: #FF0000;
    font-size: 1.4em;
    font-weight: bold;
}
h1 {
    color: #345A8B;
    font-weight: bold;
    text-transform: uppercase;
}
h2 {
    color: #FF0000;
    font-size: 1.4em;
    font-weight: bold;
    margin: 15px 0 0;
}
.classebotao {
 background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #f9f9f9), color-stop(1, #e9e9e9) );
 background:-moz-linear-gradient( center top, #f9f9f9 5%, #e9e9e9 100% );
 filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#e9e9e9');
 background-color:#f9f9f9;
 -webkit-border-top-left-radius:0px;
 -moz-border-radius-topleft:0px;
 border-top-left-radius:0px;
 -webkit-border-top-right-radius:15px;
 -moz-border-radius-topright:15px;
 border-top-right-radius:15px;
 -webkit-border-bottom-right-radius:0px;
 -moz-border-radius-bottomright:0px;
 border-bottom-right-radius:0px;
 -webkit-border-bottom-left-radius:15px;
 -moz-border-radius-bottomleft:15px;
 border-bottom-left-radius:15px;
 text-indent:0;
 border:1px solid #dcdcdc;
 display:inline-block;
 color:#666666;
 font-family:Arial;
 font-size:15px;
 font-weight:bold;
 font-style:normal;
 height:40px;
 line-height:40px;
 width:100px;
 text-decoration:none;
 text-align:center;
}
.classebotao:hover {
 background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #e9e9e9), color-stop(1, #f9f9f9) );
 background:-moz-linear-gradient( center top, #e9e9e9 5%, #f9f9f9 100% );
 filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#e9e9e9', endColorstr='#f9f9f9');
 background-color:#e9e9e9;
}.classebotao:active {
 position:relative;
 top:1px;
}
</STYLE>
<script language='vbscript'>
<!--
Sub Window_Onload
window.resizeTo 720,600
End Sub
-->
Sub Beep
BeepSound = chr(007)
CreateObject("WScript.Shell").Run "cmd /c @echo " & BeepSound, 0
End Sub
Sub Shutdown
Set objSystemSet = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown )}")_
.InstancesOf("Win32_OperatingSystem")
For Each objSystem In objSystemSet
objSystem.Win32Shutdown 5
Next
End Sub
Dim intLeft
Dim intTop
Sub Delay15
intLeft = window.screenLeft
intTop = window.screenTop
window.moveTo -2000,-2000
idTimer = window.setTimeout("ShowWindow", 720000, "VBScript")
DelayShutdown15()
End Sub
Sub Delay30
intLeft = window.screenLeft
intTop = window.screenTop
window.moveTo -2000,-2000
idTimer = window.setTimeout("ShowWindow", 1620000, "VBScript")
DelayShutdown30()
End Sub
Sub Delay60
intLeft = window.screenLeft
intTop = window.screenTop
window.moveTo -2000,-2000
idTimer = window.setTimeout("ShowWindow", 3420000, "VBScript")
DelayShutdown60()
End Sub
Sub ShowWindow
window.moveTo intLeft,intTop
window.clearTimeout(idTimer)
End Sub
Sub Resize
Window.Focus()
window.resizeTo window.screen.width+0,window.screen.height+0
window.moveto 0,0
End Sub
Sub Warn
Window.Focus()
End Sub
</script>
</head>
<body STYLE="filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#0099ff', EndColorStr='#FFFFFF')">
<div>   
<div id="top_body">
<p align="center"><img border="0" hspace="0" src="http://www.e-tab.com.br/endian/logo_proxy.jpg" width="300" height="160"></p><br>
<h1>Desligamento Programado</h1><br>
<h2>Salve agora seus trabalhos e evite perda de informa&ccedil;&otilde;es.</h2><br>
</div></div>
<p align="center">Auto desligamento do seu computador em: </p><div align="center" id="countdown"></div><br>
<p align="center">Seu computador ser&aacute; desligado automaticamente dentro de 5 minutos.<br>Caso precise de mais tempo por favor selecione as op&ccedil;&otilde;es abaixo.</p>
<p align="center">
<input type='button' class="classebotao" value='+ 15 Minutos' name='bCancle' onclick='Delay15'>
<input type='button' class="classebotao" value='+ 30 Minutos' name='bCancle' onclick='Delay30'>
<input type='button' class="classebotao" value='+ 60 Minutos' name='bCancle' onclick='Delay60'>
<br><p align="center">E-tab Tecnologia e Gest&atilde;o - <a href="http://helpdesk.e-tab.com.br">Helpdesk</a></p>
<script type="text/javascript">
var Update;
function DelayShutdown15()
{  
mins=15;
howMany = mins * 60;
Update = 1;
}
function DelayShutdown30()
{  
mins=30;
howMany = mins * 60;
Update = 1;
}
function DelayShutdown60()
{
mins=60;
howMany = mins * 60;
Update = 1;
}
beep();
var mins = 5.1;
var howMany = mins * 60;
Number.prototype.toMinutesAndSeconds = function() {
var nbr = Math.floor(this / 60);
return ((nbr>1)?nbr+" minutos ":"")+((nbr==1)?nbr+" minuto ":"")+(((nbr=(this-(nbr*60)))<10)?"0"+nbr+" segundos":nbr+" segundos"); 
}
function display(seconds, output) {
if (Update == 1)
{
Update = 0;
seconds = howMany;
}                              
output.innerHTML = (--seconds).toMinutesAndSeconds();
if(seconds > 0)
{                                                                                                    
if (seconds < 100) {   beep();  Resize();
}
window.setTimeout(function(){display(seconds, output)}, 1000);
}               
if (seconds == 0) {       
Shutdown();
}
}
display(howMany, document.getElementById("countdown"));
</script>
</body>
</html>
Printscreen.png
Você não está autorizado a ver ou baixar esse anexo.


"Transportai um punhado de terra todos os dias e fareis uma montanha." Confúcio

Voltar para “Scripts”