none
ajuda script VBS para HTA RRS feed

  • Pergunta

  • Ola senhores,

    gostaria de saber se há a possibilidade de transformar o cód. abaixo vbs em HTA e add. alguns comandos como por exemplo:

    Nome: (espaço em branco para digitar)
    Equipamento Formatado: (utilizar check box, sim ou não)
    Kill Disk:  (utilizar check box, sim ou não)
    validado por:(espaço em branco para digitar)
    Data:(espaço em branco para digitar)

    script vbs:

     Name = InputBox("Digite o NOVO HOSTNAME e clique em OK para continuar","Rename: Step 1")
    Password = InputBox("Digite um usuário ADM")
    Username = InputBox("Digite a senha ADM")
    Set objWMIService = GetObject("Winmgmts:root\cimv2")
    ' Call always gets only one Win32_ComputerSystem object.
    For Each objComputer in _
       objWMIService.InstancesOf("Win32_ComputerSystem")
           Return = objComputer.rename(Name,Password,User)
           If Return <> 0 Then
              WScript.Echo "Rename failed. Error = " & Err.Number
           Else
              WScript.Echo "Rename succeeded." & " O micro precisará ser reiniciado para validar as mudanças feitas"
           End If
     
    Next
     
    DomainName = InputBox("Digite o DOMINIO a ser add e clique em OK para continuar","Rename: Step 1")
    DomainPassword = InputBox("Digite um usuário ADM")
    DomainUsername = InputBox("Digite a senha ADM")
    Set objWMIService = GetObject("Winmgmts:root\cimv2")
    ' Call always gets only one Win32_ComputerSystem object.
    For Each objComputer in _
       objWMIService.InstancesOf("Win32_ComputerSystem")
           Return = objComputer.JoinDomainOrWorkgroup(DomainName,DomainPassword,DomainUsername)
           If Return <> 0 Then
              WScript.Echo "Rename failed. Error = " & Err.Number
           Else
              WScript.Echo "Rename succeeded." & " REINICIE o equipamento para validar as novas configurações"
           End If
     
    Next 

    desde já agradeço a atenção e ajuda

    quarta-feira, 20 de junho de 2012 16:16

Respostas

  • Quina,

    O link que vou te passar ajuda muito na criação de HTAs.

    Mesclei três códigos fornecidos por ele: Create Basic HTA , Text Box e Button

    <html>
    <head>
    <title>HTA Helpomatic</title>
    
    <HTA:APPLICATION 
         ID="objHTAHelpomatic"
         APPLICATIONNAME="HTAHelpomatic"
         SCROLL="yes"
         SINGLEINSTANCE="yes"
         WINDOWSTATE="maximize"
    >
    </head>
    
    <SCRIPT Language="VBScript">
    	'Displays a message box when the button is clicked
    	Sub RunScript
    	    Msgbox BasicTextBox.Value
    
    	End Sub
    </SCRIPT>
    <body>
    
    	Validado por:<input type="text" name="BasicTextBox" size="50"><BR>
    	<input id=runbutton  class="button" type="button" value="Run Button" name="run_button"  onClick="RunScript">
    </body>
    </html>

    Já tem um text box e um botão que executa ação. Vá adicionando os outros objetos que você precisa, se estiver com alguma dificuldade retorne aqui com o seu código alterado.

    HTA Helpomatic

    www.microsoft.com/en-us/download/details.aspx?id=17332


    Fábio de Paula Junior

    quarta-feira, 20 de junho de 2012 20:09
    Moderador

Todas as Respostas

  • Quina,

    O link que vou te passar ajuda muito na criação de HTAs.

    Mesclei três códigos fornecidos por ele: Create Basic HTA , Text Box e Button

    <html>
    <head>
    <title>HTA Helpomatic</title>
    
    <HTA:APPLICATION 
         ID="objHTAHelpomatic"
         APPLICATIONNAME="HTAHelpomatic"
         SCROLL="yes"
         SINGLEINSTANCE="yes"
         WINDOWSTATE="maximize"
    >
    </head>
    
    <SCRIPT Language="VBScript">
    	'Displays a message box when the button is clicked
    	Sub RunScript
    	    Msgbox BasicTextBox.Value
    
    	End Sub
    </SCRIPT>
    <body>
    
    	Validado por:<input type="text" name="BasicTextBox" size="50"><BR>
    	<input id=runbutton  class="button" type="button" value="Run Button" name="run_button"  onClick="RunScript">
    </body>
    </html>

    Já tem um text box e um botão que executa ação. Vá adicionando os outros objetos que você precisa, se estiver com alguma dificuldade retorne aqui com o seu código alterado.

    HTA Helpomatic

    www.microsoft.com/en-us/download/details.aspx?id=17332


    Fábio de Paula Junior

    quarta-feira, 20 de junho de 2012 20:09
    Moderador
  • Ola Fabio, muito agradecido pela ajuda, vou fazer os testes e retorno assim que finalizar. É que sou novo no assunto de vbs/hta... mas responderei o mais breve possivel

    vlw pela ajuda até o momento

    abx

    quarta-feira, 20 de junho de 2012 20:56
  • Consegui fazer algumas coisas, logo mais postarei aqui e pedirei ajuda
    terça-feira, 26 de junho de 2012 21:27
  • Senhores, consegui fazer com que as maquinas ingressem no dominio, mas nao consigo fazer com que me gere um relatorio

    <html>
    	<head>
    	<title>Incluir micro no Dominio</title>
    
    	<HTA:APPLICATION 
    		 APPLICATIONNAME="Incluir micro no Dominio"
    		 SCROLL="No"
    		 SINGLEINSTANCE="Yes"
    		 borderstyle="Thin"
    		 minimizebutton="No"
    		 maximizebutton="No"
    		 icon=""
    	>
    
    	<style type="text/css">
    		/* <![CDATA[ */
    		BODY {
    			background-color: rgb(0,0,0);
    			color: white;
    			margin: 10px 10px 10px 10px;
    			font: 14px Verdana;  
    		}
    		#status_bar {
    			box-shadow:rgb(136, 136, 136) 0px 5px 5px;
    			background-color:#F7F7F7;
    			border:1px solid #A5A5A5;
    			font-color: #A5A5A5;
    			font-size: 70%;
    			border-bottom:0px;
    			bottom:0px;
    			height:25px;
    			margin:auto;
    			padding:5px 5px 5px 5px;
    			position:absolute;
    			width:100%;
    			z-index:500;
    
    		}
    		.texta {  
    			font-size: 14px;  
    			background-color: white;  
    			border: 1px solid #666666;  
    		}
    
    		/* ]]> */
    	</style>
     
    	</head>
    	<body><center>
    		<br>
    		<h2>Incluir micro no Dominio</h2>
    		<br><br>
    		Hostname: <input type="text" maxlength="20" size="30" name="txt_computername">
    		<br><br>
    		Usuário: <input type="text" maxlength="20" size="40" name="txt_username">
    		<br><br>
    		Senha: <input type="password" maxlength="20" size="40" name="txt_password">
    		<br><br>
    		<input type="button" value="Incluir no Dominio" onClick="vbs:add2Domain">
    		<br><br>
    		</center>
     
    		<SCRIPT Language="VBScript">
     
    		Sub Window_OnLoad
    			intHeight = 480
    			intWidth = 600
    			Me.ResizeTo intWidth, intHeight
    			Me.MoveTo (screen.width / 2) - (intWidth / 2), (screen.height / 2) - (intHeight / 2)
    			Set objNetwork = CreateObject("WScript.Network")
    			txt_computername.Value = objNetwork.ComputerName
    		End Sub
    		
    		Sub add2Domain 
    			If Trim(txt_username.Value) = "" Then
    				MsgBox "Please enter a username."
    				txt_username.Focus
    			ElseIf Trim(txt_password.value) = "" Then
    				MsgBox "Please enter a password."
    				txt_password.Focus
    			Else
    				On Error Resume Next 
    				Const ADS_SCOPE_SUBTREE = 2
    				Const ADS_SECURE_AUTHENTICATION = 1
    				Const HKEY_LOCAL_MACHINE = &H80000002
    				Const ForReading = 1
    				Const ForWriting = 2
    				Dim strDomain, strPassword, strUser, strAdsPath, strOU,fPath
    				Set WshShell =WScript.CreateObject("Wscript.Shell")
    				Set objFSO = CreateObject("Scripting.FileSystemObject")
    				UserProfile = WshShell.ExpandEnvironmentStrings("%userprofile%")
    				strLogDir = UserProfile&"\Desktop\"
    				strDomain   = "TEST"
    				strComputer=Trim(txt_computername.Value)
    				strPassword=Trim(txt_password.Value)
    				strUser=Trim(txt_username.Value)
    				If objFSO.FileExists(strLogDir & "Domain Log.txt") Then
    					Set objFile = objFso.OpenTextFile(strLogDir & "Domain Log.txt",ForWriting)
    					objFile.WriteLine "Log Started : " & Now
    					objFile.WriteLine
    					DelAcct()
    					Join2Domain()
    					objFile.Writeline "Log Ended :" & NOW
    					objFile.close
    				Else
    					fPath=strLogDir & "Domain Log.txt"
    					Set objFile = objFso.CreateTextFile (fPath, True)
    					objFile.WriteLine "Log Started : " & Now
    					objFile.WriteLine
    					DelAcct()
    					Join2Domain()
    					objFile.Writeline "Computer Booted :" & NOW
    					objFile.close
    				End If
    				
    				ShutDown strComputer
    			End If
    		End Sub
    		
    		Function ShutDown(strComputer)
    			Set objWMIService = GetObject("winmgmts:" _
    				& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")
    			E = objWMIService.Create("cmd /c shutdown -r -t 30 ", null, null, intProcessID) 
    			'Set objWMIService = GetObject("winmgmts:" _
    			'& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    			Set WMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
    			Set OperatingSystems = WMIService.ExecQuery("Select * From Win32_OperatingSystem")
    			For Each OperatingSystem in OperatingSystems
    				OperatingSystem.Reboot()
    			Next
    			if E = 0 Then
    				ShutDown  = "OK"
    			end If
    		End Function
    		
    		Function DelAcct()
    			Set objConnection = CreateObject("ADODB.Connection")
    			Set objCommand =   CreateObject("ADODB.Command")
    			objConnection.Provider = "ADsDSOObject"
    			objConnection.Properties("User ID") = strDomain&"\"&strUser
    			objConnection.Properties("Password") = strPassword
    			objConnection.Properties("Encrypt Password") = True
    			objConnection.Properties("ADSI Flag") = 1
    			objConnection.Open "Active Directory Provider"
    			Set objCommand.ActiveConnection = objConnection
    			objCommand.Properties("Page Size") = 100
    			objCommand.Properties("Cache Results") = False
    			objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
    
    			objCommand.CommandText = _
    				"SELECT ADsPath FROM 'LDAP://" & strDomain & ".com" & "' WHERE objectCategory='computer' " & _
    				"AND Name='" & strComputer & "'"
    			Set objRecordSet = objCommand.Execute
    			If objRecordSet.EOF Then
    				MsgBox "Computer not found."
    				objFile.WriteLine "Computer not found."
    			Else
    				objRecordSet.MoveFirst
    				While Not objRecordSet.EOF
    					strAdsPath = objRecordSet.Fields("ADsPath").Value
    					intDNLength = Len(strAdsPath)- Len("LDAP://"&strDomain&".com/CN=")-Len (strComputer)-Len (",")
    					strOU=Right(strAdsPath, intDNLength)
    					objRecordSet.MoveNext
    					Wend
    
    				Set objADS = GetObject("LDAP:")
    				Set objComputer =  objADS.OpenDSObject(strAdsPath, strDomain&"\"&strUser, strPassword,ADS_SECURE_AUTHENTICATION)
    				objComputer.DeleteObject (0)
    
    				objFile.WriteLine "Computer path: " & strOU
    				MsgBox "Computer was removed from AD "
    				objFile.WriteLine "Computer was removed from AD "
    			End If
    		End Function
    			
    		Function Join2Domain()
    			Const JOIN_DOMAIN             = 1
    			Const ACCT_CREATE             = 2
    			Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    				strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
    				strComputer & "'")
    			ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    							strPassword, _
    							strDomain & "\" & strUser, _
    							strOU, _
    							JOIN_DOMAIN + ACCT_CREATE)
    			If ReturnValue = 5 Then
    				objFile.WriteLine "Access was Denied for adding the Computer to the Domain"
    				objFile.WriteLine "RetureValue: " & ReturnValue
    			End If
    			If ReturnValue = 2224 Then
    				objFile.WriteLine "Account exists in the Domain"
    				objFile.WriteLine "RetureValue: " & ReturnValue
    			End If
    			If ReturnValue = 0 Then
    				objFile.WriteLine "The Computer was sucssefully added to the domain"
    				objFile.WriteLine "RetureValue: " & ReturnValue
    			End if
    			If ReturnValue > 2691 Then
    				objFile.WriteLine "The Computer was sucssefully added to the domain"
    				objFile.WriteLine "RetureValue: " & ReturnValue
    			Else
    				objFile.WriteLine "The Computer failed to join domain: "& strDomain
    				objFile.WriteLine "RetureValue: " & ReturnValue
    			End If
    		End Function
    	</Script>
    	</body>
    </html>



    • Editado Fábio JrModerator quinta-feira, 28 de junho de 2012 02:40 Formatação do código
    quarta-feira, 27 de junho de 2012 22:08
  • Quina,

    Não esta funcionando porque vc não criou o objFile dentro da função Join2Domain, este objeto foi instanciado na add2Domain.

    Tente o seguinte:

    1)Altere esta parte:

    				If objFSO.FileExists(strLogDir & "Domain Log.txt") Then
    					Set objFile = objFso.OpenTextFile(strLogDir & "Domain Log.txt",ForWriting)
    					objFile.WriteLine "Log Started : " & Now
    					objFile.WriteLine
    					DelAcct()
    					ReturnValue=Join2Domain()
    					objFile.Writeline "Log Ended :" & NOW
    					objFile.close
    				Else
    					fPath=strLogDir & "Domain Log.txt"
    					Set objFile = objFso.CreateTextFile (fPath, True)
    					objFile.WriteLine "Log Started : " & Now
    					objFile.WriteLine
    					DelAcct()
    					ReturnValue=Join2Domain()
    					objFile.Writeline "Computer Booted :" & NOW
    					objFile.close
    				End If
    				
    				
    	
    				If ReturnValue = 5 Then
    					objFile.WriteLine "Access was Denied for adding the Computer to the Domain"
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				End If
    				If ReturnValue = 2224 Then
    					objFile.WriteLine "Account exists in the Domain"
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				End If
    				If ReturnValue = 0 Then
    					objFile.WriteLine "The Computer was sucssefully added to the domain"
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				End if
    				If ReturnValue > 2691 Then
    					objFile.WriteLine "The Computer was sucssefully added to the domain"
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				Else
    					objFile.WriteLine "The Computer failed to join domain: "& strDomain
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				End If
    					
    				
    				ShutDown strComputer

    Veja que na frente do Join2Domain eu coloquei uma variavel para receber uma valor vindo de Join2Domain.

    E aquela parte que escrevia dentro do Join2Domain eu coloque depois do final do IF. Quer dizer eu coloquei o objFile dentro de uma função onde ele foi criado.

    2)Modifique o Join2Domain

    		Function Join2Domain()
    			Const JOIN_DOMAIN             = 1
    			Const ACCT_CREATE             = 2
    			Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    				strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
    				strComputer & "'")
    			Join2Domain = objComputer.JoinDomainOrWorkGroup(strDomain, _
    							strPassword, _
    							strDomain & "\" & strUser, _
    							strOU, _
    							JOIN_DOMAIN + ACCT_CREATE)
    			
    			
    		End Function

    Viu, tirei a parte que escreve no log e coloquei a variavel Join2Domain para receber o resultado do comando que coloca no dominio, esse resultado vai voltar lá pra função que chamou esta.


    Fábio de Paula Junior

    quinta-feira, 28 de junho de 2012 02:54
    Moderador
  • Código completo, não testei.

    <html>
    	<head>
    	<title>Incluir micro no Dominio</title>
    
    	<HTA:APPLICATION 
    		 APPLICATIONNAME="Incluir micro no Dominio"
    		 SCROLL="No"
    		 SINGLEINSTANCE="Yes"
    		 borderstyle="Thin"
    		 minimizebutton="No"
    		 maximizebutton="No"
    		 icon=""
    	>
    
    	<style type="text/css">
    		/* <![CDATA[ */
    		BODY {
    			background-color: rgb(0,0,0);
    			color: white;
    			margin: 10px 10px 10px 10px;
    			font: 14px Verdana;  
    		}
    		#status_bar {
    			box-shadow:rgb(136, 136, 136) 0px 5px 5px;
    			background-color:#F7F7F7;
    			border:1px solid #A5A5A5;
    			font-color: #A5A5A5;
    			font-size: 70%;
    			border-bottom:0px;
    			bottom:0px;
    			height:25px;
    			margin:auto;
    			padding:5px 5px 5px 5px;
    			position:absolute;
    			width:100%;
    			z-index:500;
    
    		}
    		.texta {  
    			font-size: 14px;  
    			background-color: white;  
    			border: 1px solid #666666;  
    		}
    
    		/* ]]> */
    	</style>
     
    	</head>
    	<body>
    		<center>
    			<br>
    			<h2>Incluir micro no Dominio</h2>
    			<br><br>
    			Hostname: <input type="text" maxlength="20" size="30" name="txt_computername">
    			<br><br>
    			Usuário: <input type="text" maxlength="20" size="40" name="txt_username">
    			<br><br>
    			Senha: <input type="password" maxlength="20" size="40" name="txt_password">
    			<br><br>
    			<input type="button" value="Incluir no Dominio" onClick="vbs:add2Domain">
    			<br><br>
    		</center>
     
    		<SCRIPT Language="VBScript">
     
    		Sub Window_OnLoad
    			intHeight = 480
    			intWidth = 600
    			Me.ResizeTo intWidth, intHeight
    			Me.MoveTo (screen.width / 2) - (intWidth / 2), (screen.height / 2) - (intHeight / 2)
    			Set objNetwork = CreateObject("WScript.Network")
    			txt_computername.Value = objNetwork.ComputerName
    		End Sub
    		
    		Sub add2Domain 
    			If Trim(txt_username.Value) = "" Then
    				MsgBox "Please enter a username."
    				txt_username.Focus
    			ElseIf Trim(txt_password.value) = "" Then
    				MsgBox "Please enter a password."
    				txt_password.Focus
    			Else
    				On Error Resume Next 
    				Const ADS_SCOPE_SUBTREE = 2
    				Const ADS_SECURE_AUTHENTICATION = 1
    				Const HKEY_LOCAL_MACHINE = &H80000002
    				Const ForReading = 1
    				Const ForWriting = 2
    				Dim strDomain, strPassword, strUser, strAdsPath, strOU,fPath
    				Set WshShell =WScript.CreateObject("Wscript.Shell")
    				Set objFSO = CreateObject("Scripting.FileSystemObject")
    				UserProfile = WshShell.ExpandEnvironmentStrings("%userprofile%")
    				strLogDir = UserProfile&"\Desktop\"
    				strDomain   = "TEST"
    				strComputer=Trim(txt_computername.Value)
    				strPassword=Trim(txt_password.Value)
    				strUser=Trim(txt_username.Value)
    				If objFSO.FileExists(strLogDir & "Domain Log.txt") Then
    					Set objFile = objFso.OpenTextFile(strLogDir & "Domain Log.txt",ForWriting)
    					objFile.WriteLine "Log Started : " & Now
    					objFile.WriteLine
    					DelAcct()
    					ReturnValue=Join2Domain()
    					objFile.Writeline "Log Ended :" & NOW
    					objFile.close
    				Else
    					fPath=strLogDir & "Domain Log.txt"
    					Set objFile = objFso.CreateTextFile (fPath, True)
    					objFile.WriteLine "Log Started : " & Now
    					objFile.WriteLine
    					DelAcct()
    					ReturnValue=Join2Domain()
    					objFile.Writeline "Computer Booted :" & NOW
    					objFile.close
    				End If
    				
    				
    				If ReturnValue = 5 Then
    					objFile.WriteLine "Access was Denied for adding the Computer to the Domain"
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				End If
    				If ReturnValue = 2224 Then
    					objFile.WriteLine "Account exists in the Domain"
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				End If
    				If ReturnValue = 0 Then
    					objFile.WriteLine "The Computer was sucssefully added to the domain"
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				End if
    				If ReturnValue > 2691 Then
    					objFile.WriteLine "The Computer was sucssefully added to the domain"
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				Else
    					objFile.WriteLine "The Computer failed to join domain: "& strDomain
    					objFile.WriteLine "RetureValue: " & ReturnValue
    				End If
    				
    				ShutDown strComputer
    			End If
    		End Sub
    		
    		Function ShutDown(strComputer)
    			Set objWMIService = GetObject("winmgmts:" _
    				& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2:Win32_Process")
    			E = objWMIService.Create("cmd /c shutdown -r -t 30 ", null, null, intProcessID) 
    			'Set objWMIService = GetObject("winmgmts:" _
    			'& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    			Set WMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
    			Set OperatingSystems = WMIService.ExecQuery("Select * From Win32_OperatingSystem")
    			For Each OperatingSystem in OperatingSystems
    				OperatingSystem.Reboot()
    			Next
    			if E = 0 Then
    				ShutDown  = "OK"
    			end If
    		End Function
    		
    		Function DelAcct()
    			Set objConnection = CreateObject("ADODB.Connection")
    			Set objCommand =   CreateObject("ADODB.Command")
    			objConnection.Provider = "ADsDSOObject"
    			objConnection.Properties("User ID") = strDomain&"\"&strUser
    			objConnection.Properties("Password") = strPassword
    			objConnection.Properties("Encrypt Password") = True
    			objConnection.Properties("ADSI Flag") = 1
    			objConnection.Open "Active Directory Provider"
    			Set objCommand.ActiveConnection = objConnection
    			objCommand.Properties("Page Size") = 100
    			objCommand.Properties("Cache Results") = False
    			objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
    
    			objCommand.CommandText = _
    				"SELECT ADsPath FROM 'LDAP://" & strDomain & ".com" & "' WHERE objectCategory='computer' " & _
    				"AND Name='" & strComputer & "'"
    			Set objRecordSet = objCommand.Execute
    			If objRecordSet.EOF Then
    				MsgBox "Computer not found."
    				objFile.WriteLine "Computer not found."
    			Else
    				objRecordSet.MoveFirst
    				While Not objRecordSet.EOF
    					strAdsPath = objRecordSet.Fields("ADsPath").Value
    					intDNLength = Len(strAdsPath)- Len("LDAP://"&strDomain&".com/CN=")-Len (strComputer)-Len (",")
    					strOU=Right(strAdsPath, intDNLength)
    					objRecordSet.MoveNext
    					Wend
    
    				Set objADS = GetObject("LDAP:")
    				Set objComputer =  objADS.OpenDSObject(strAdsPath, strDomain&"\"&strUser, strPassword,ADS_SECURE_AUTHENTICATION)
    				objComputer.DeleteObject (0)
    
    				objFile.WriteLine "Computer path: " & strOU
    				MsgBox "Computer was removed from AD "
    				objFile.WriteLine "Computer was removed from AD "
    			End If
    		End Function
    			
    		Function Join2Domain()
    			Const JOIN_DOMAIN             = 1
    			Const ACCT_CREATE             = 2
    			Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
    				strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
    				strComputer & "'")
    			Join2Domain = objComputer.JoinDomainOrWorkGroup(strDomain, _
    							strPassword, _
    							strDomain & "\" & strUser, _
    							strOU, _
    							JOIN_DOMAIN + ACCT_CREATE)
    
    		End Function
    	</Script>
    	</body>
    </html>

    Fábio de Paula Junior



    quinta-feira, 28 de junho de 2012 02:56
    Moderador
  • Desculpa a demora Fábio, vou testar e respondo, muito agradecido pela ajuda
    sexta-feira, 13 de julho de 2012 11:13
  • Quina

    Ba bom dia.

    Cara me de uma força com este seu HTA tche, estou tentando usar e estou tendo o erro que postei neste link.

    http://social.technet.microsoft.com/Forums/pt-BR/93499e6e-cff2-41ec-a5f2-c6cb7da3495d/script-vbs-em-hta-para-adicionar-maquina-no-domino-com-erro

    Gostei muito da sua ideia tche, se tiver como me ajudar lhe agradeço muito.

    mas uma pergunta, com ele é possível colocar uma estação remotamente no domínio.

    obrigado.

    segunda-feira, 1 de julho de 2013 10:58