none
Campo password en Vbscript? Posible? RRS feed

  • Pregunta

  • Buenas he conseguido, buscando i buscando, crear el siguiente  vbscript para validar usuarios con unidades de red i que estas se monten, però me gustaria que el campo password saliera con (*******) asteriscos es posible?

    Aqui os dejo el script por si a alguien le interesa:
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    Dim WshNetwork
    Dim strPassword
    Dim strUser
    Dim strLletra
    Dim strCarpeta

    'Demanar USUARI i PASSWORD

    'Borra totes les unitats de xarxa, si l'usuari vol
    Set WshNet = Wscript.CreateObject("WScript.Network")
    Set unidades_de_red = WshNet.EnumNetworkDrives

    If unidades_de_red.count> 0 then
    borrar = msgbox("¿Borrar les unitats de X?", vbQuestion+vbYesNo,"Redes")
    If borrar = vbYes then
    For n_prueba = 26 To 5 Step -1
    num = chr(n_prueba + 64) & ":"
    On Error Resume Next
    WshNet.RemoveNetworkDrive num , True
    Next
    End if
    End if

    strUser = InputBox ("USUARI: ", "Connectant Arees")
    strPassword = InputBox ("PASSWORD: ", "Connectant Arees")
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set fso = CreateObject("Scripting.FileSystemObject")
    WshNetwork.MapNetworkDrive "P:", "\\192.9.201.5\programes", true, strUser, strPassword
    WshNetwork.MapNetworkDrive "U:", "\\192.9.201.5\docu", true, strUser, strPassword
    WshNetwork.MapNetworkDrive "B:", "\\192.9.201.5\basket", true, strUser, strPassword
    WshNetwork.MapNetworkDrive "I:", "\\192.9.201.5\si", true, strUser, strPassword
    WshNetwork.MapNetworkDrive "O:", "\\192.9.201.5\copiapcs", true, strUser, strPassword

    'Liberamos la memoria
    Set WshNet = Nothing
    Set WshShell = Nothing
    Set fso = Nothing
    Set Unidades_de_red = Nothing

    WScript.Quit()


    -----------------------------------------------------------------------------------------------------------------------------------------------------


    Gracias
    lunes, 21 de enero de 2008 16:00

Respuestas

  • Conseguido Prueba superada.... validacion de usuario con Vbscript i formulario HTML.

    BLOCKED SCRIPT------------------------------------------------------------------------------------------------------------

    Option Explicit
    Dim WshNetwork,WshNet
    Dim strPassword, pwd, objExplorer, strButton
    Dim strUser, fso, borrar, n_prova, num
    Dim strLletra,WshShell
    Dim strCarpeta, d, mess
    Dim unitats_de_xarxa

    'Borra totes les unitats de xarxa

    Set WshNet = Wscript.CreateObject("WScript.Network")
    Set unitats_de_xarxa = WshNet.EnumNetworkDrives

    //si hi ha arees les reinicialitza

    If unitats_de_xarxa.count> 0 then
    borrar = msgbox("¿Borrar les unitats de X?", vbQuestion+vbYesNo,"Redes")
    If borrar = vbYes then
    For n_prova = 26 To 5 Step -1
    num = chr(n_prova + 64) & ":"
    On Error Resume Next
    WshNet.RemoveNetworkDrive num , True
    Next
    End if
    End if

    'Demanar USUARI i PASSWORD
    Set objExplorer = WScript.CreateObject ("InternetExplorer.Application", "IE_")

    objExplorer.Navigate "C:\Arees\pass.htm"  
    objExplorer.ToolBar = 0
    objExplorer.StatusBar = 0
    objExplorer.Width = 350
    objExplorer.Height = 280
    objExplorer.Left = 300
    objExplorer.Top = 200
    objExplorer.Visible = 1            

    Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
        Wscript.Sleep 350                
    Loop

    strUser = objExplorer.Document.Body.All.User.Value
    strPassword = objExplorer.Document.Body.All.UserPassword.Value
    strButton = objExplorer.Document.Body.All.OKClicked.Value
    objExplorer.Quit
    Wscript.Sleep 350

    'Munta les arees de Xarxa

    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set fso = CreateObject("Scripting.FileSystemObject")
    WshNetwork.MapNetworkDrive "P:", "\\IP\carpeta", true, strUser, strPassword


    'Llibera memoria
    Set WshNet = Nothing
    Set WshShell = Nothing
    Set fso = Nothing
    Set unitats_de_xarxa = Nothing
    Set WshNetwork = Nothing

    WScript.Quit()

    =====================================================================

    CODIGO HTML----------------------------------------------------------------------------------------------------------------------

    <SCRIPT LANGUAGE="VBScript">

    Sub RunScript
        OKClicked.Value = "OK"
    End Sub

    Sub CancelScript
        OKClicked.Value = "Cancelled"
    End Sub

    </SCRIPT>

    <BODY>
       


        <table width="200" border="0">
         <tr>
        <td align="center" colspan="2"><img src="logotipo.jpg" width="160" height="75" border="1">
          <br><br><font size="2" face="Arial">ACC&Eacute;S &Agrave;REES DE XARXA <font></td>
        </tr>
      <tr>
        <td><font size="2" face="Arial">
      Usuari: </font></td>
        <td><input name="User" size="30"></td>
      </tr>
      <tr>
        <td><font size="2" face="Arial">Contrasenya:&nbsp;&nbsp;</font></td>
        <td><input type="password" name="UserPassword" size="30"></td>
      </tr>
      <tr>
        <td align="center" colspan="2"><input type="hidden" name="OKClicked" size = "20">
      <input id=runbutton class="button" type="button" value=" OK " name="ok_button" onClick="RunScript">
      <input id=runbutton class="button" type="button" value="Cancel" name="cancel_button" onClick="CancelScript"></td>
      </tr>
    </table>
    </BODY>
    ====================================================================================

    Espero que os sirva!!

    Saludos!
    miércoles, 6 de febrero de 2008 8:11

Todas las respuestas

  • Hola de nuevo,

     

    Para lo que tu quieres este link quizas te va mejor:

    http://www.experts-exchange.com/Programming/Misc/Q_22102440.html

     

    lunes, 21 de enero de 2008 16:21
  • Conseguido Prueba superada.... validacion de usuario con Vbscript i formulario HTML.

    BLOCKED SCRIPT------------------------------------------------------------------------------------------------------------

    Option Explicit
    Dim WshNetwork,WshNet
    Dim strPassword, pwd, objExplorer, strButton
    Dim strUser, fso, borrar, n_prova, num
    Dim strLletra,WshShell
    Dim strCarpeta, d, mess
    Dim unitats_de_xarxa

    'Borra totes les unitats de xarxa

    Set WshNet = Wscript.CreateObject("WScript.Network")
    Set unitats_de_xarxa = WshNet.EnumNetworkDrives

    //si hi ha arees les reinicialitza

    If unitats_de_xarxa.count> 0 then
    borrar = msgbox("¿Borrar les unitats de X?", vbQuestion+vbYesNo,"Redes")
    If borrar = vbYes then
    For n_prova = 26 To 5 Step -1
    num = chr(n_prova + 64) & ":"
    On Error Resume Next
    WshNet.RemoveNetworkDrive num , True
    Next
    End if
    End if

    'Demanar USUARI i PASSWORD
    Set objExplorer = WScript.CreateObject ("InternetExplorer.Application", "IE_")

    objExplorer.Navigate "C:\Arees\pass.htm"  
    objExplorer.ToolBar = 0
    objExplorer.StatusBar = 0
    objExplorer.Width = 350
    objExplorer.Height = 280
    objExplorer.Left = 300
    objExplorer.Top = 200
    objExplorer.Visible = 1            

    Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
        Wscript.Sleep 350                
    Loop

    strUser = objExplorer.Document.Body.All.User.Value
    strPassword = objExplorer.Document.Body.All.UserPassword.Value
    strButton = objExplorer.Document.Body.All.OKClicked.Value
    objExplorer.Quit
    Wscript.Sleep 350

    'Munta les arees de Xarxa

    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set fso = CreateObject("Scripting.FileSystemObject")
    WshNetwork.MapNetworkDrive "P:", "\\IP\carpeta", true, strUser, strPassword


    'Llibera memoria
    Set WshNet = Nothing
    Set WshShell = Nothing
    Set fso = Nothing
    Set unitats_de_xarxa = Nothing
    Set WshNetwork = Nothing

    WScript.Quit()

    =====================================================================

    CODIGO HTML----------------------------------------------------------------------------------------------------------------------

    <SCRIPT LANGUAGE="VBScript">

    Sub RunScript
        OKClicked.Value = "OK"
    End Sub

    Sub CancelScript
        OKClicked.Value = "Cancelled"
    End Sub

    </SCRIPT>

    <BODY>
       


        <table width="200" border="0">
         <tr>
        <td align="center" colspan="2"><img src="logotipo.jpg" width="160" height="75" border="1">
          <br><br><font size="2" face="Arial">ACC&Eacute;S &Agrave;REES DE XARXA <font></td>
        </tr>
      <tr>
        <td><font size="2" face="Arial">
      Usuari: </font></td>
        <td><input name="User" size="30"></td>
      </tr>
      <tr>
        <td><font size="2" face="Arial">Contrasenya:&nbsp;&nbsp;</font></td>
        <td><input type="password" name="UserPassword" size="30"></td>
      </tr>
      <tr>
        <td align="center" colspan="2"><input type="hidden" name="OKClicked" size = "20">
      <input id=runbutton class="button" type="button" value=" OK " name="ok_button" onClick="RunScript">
      <input id=runbutton class="button" type="button" value="Cancel" name="cancel_button" onClick="CancelScript"></td>
      </tr>
    </table>
    </BODY>
    ====================================================================================

    Espero que os sirva!!

    Saludos!
    miércoles, 6 de febrero de 2008 8:11