IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Informations de session à distance


Sujet :

VBScript

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre expérimenté
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Novembre 2011
    Messages
    163
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Novembre 2011
    Messages : 163
    Par défaut Informations de session à distance
    Bonjour,

    Je voudrais pouvoir exécuter mon script de nettoyage des profils locaux à distance (je suis un peu feignant, je préfère travailler de mon bureau !)

    Pour cela, j'ai besoin de savoir si le poste distant est accessible (ça c'est ok, merci pour le code de test de ping).
    Mais surtout j'aurais besoin de savoir s'il y a une session ouverte sur le poste et si oui, avec quel nom d'utilisateur ...

    Cela est-il possible ?

  2. #2
    Expert confirmé
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 844
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 844
    Par défaut
    Citation Envoyé par Cachlab Voir le message
    Bonjour,
    Je voudrais pouvoir exécuter mon script de nettoyage des profils locaux à distance (je suis un peu feignant, je préfère travailler de mon bureau !)
    Pour cela, j'ai besoin de savoir si le poste distant est accessible (ça c'est ok, merci pour le code de test de ping).
    Mais surtout j'aurais besoin de savoir s'il y a une session ouverte sur le poste et si oui, avec quel nom d'utilisateur ...
    Cela est-il possible ?

    Voila un Bon HTA en Anglais trouvé sur le Net Login_Details.hta
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    <title>Login Details of a Machine</title>
    <HTA:APPLICATION
    APPLICATIONNAME="Login Details"
    BORDER="thin"
    SCROLL="no"
    SINGLEINSTANCE="yes"
    WINDOWSTATE="normal"></head>
     
    <script language="VBScript">
     
    Sub Window_onLoad
    Me.ResizeTo 400,300
    Me.MoveTo ((Screen.Width / 2) - 200),((Screen.Height / 2) - 150)
    End Sub
     
    Sub Default_Buttons
    If Window.Event.KeyCode = 13 Then
    btn_logindetails.Click
    End If
    End Sub
     
    Sub Get_Login_Details
    strComputer = txt_computer.value
    if strComputer = "" Then
    msgbox "Please enter a computer name or IP Address",vbOKOnly,"No Computer Name or IP Address"
    Exit Sub
    End If
     
    If Ping(strComputer) = False Then
    msgbox strComputer & " did not respond to ping. No action could be taken.",vbOkOnly, "Cannot continue script."
    Exit Sub
    End If
     
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
     
    Set colComputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
     
    Set colComputerIP = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration")
     
    Set colSystemInfo = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem",,48)
     
    For Each objComputer in colComputer
    strUserName = "User Name: " & objComputer.UserName
    strHostName = "Host Name: " & objComputer.Name
    Next
     
    For Each IPConfig in colComputerIP
    If Not IsNull(IPConfig.IPAddress) Then
    For intIPCount = LBound(IPConfig.IPAddress) _
    to UBound(IPConfig.IPAddress)
    strIPAddress = strIPAddress & "IP Address: " & IPConfig.IPAddress(intIPCount) & "~"
    next
    end if
    Next
     
    If Right(strIPAddress, 1) = "~" Then
    strIPAddress = Left(strIPAddress, Len(strIPAddress) - 1)
    End If
    strIPAddress = Replace(strIPAddress, "~", vbCrLf)
     
    For Each objItem in colSystemInfo
    strOS_Caption = "Caption: " & objItem.Caption
    strOS_SPVersion = "SP Version: " & objItem.CSDVersion
    strOS_VerNumber = "Version Number: " & objItem.Version
    Next
     
    MsgBox strUserName & vbcrlf & strHostName & vbcrlf & _
    strIPAddress & vbcrlf & strOS_Caption & vbcrlf & _
    strOS_SPVersion & vbcrlf & strOS_VerNumber, vbOKOnly, "Login Details"
    End Sub
     
    Function Ping(strComputer)
    Dim objShell, boolCode
    Set objShell = CreateObject("WScript.Shell")
    boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
    If boolCode = 0 Then
    Ping = True
    Else
    Ping = False
    End If
    End Function
    </script>
     
    <body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
    <table width='80%' height = '100%' align='center' border='0'><tr height='20%'><td></td></tr>
    <tr height='10%'><td align='center'>Computer name or IP Address:</td></tr
    <tr height='20%'><td align='center'>
    <input type="text" value="172.16.2.48" name="txt_computer" maxlength='15' size='16'>
    </td></tr><tr height='30%'><td align='center'>
    <input type="button" value="Check Machine" name="btn_logindetails"  onClick="Get_Login_Details">
    </td></tr><tr height='20%'><td></td></tr></table></body>
    Bonne Programmation

  3. #3
    Membre expérimenté
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Novembre 2011
    Messages
    163
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Novembre 2011
    Messages : 163
    Par défaut
    Merci, c'est génial ! C'est exactement ce qu'il me fallait.

    T'es un chef hackoofr !

    Bien, histoire de participer un peu, voici ma version française ...
    (J'espère que l'auteur ne m'en voudra pas !)
    Si ça peut servir à quelqu'un d'autre ...

    Login_Details_VF.hta
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
     
    <title>Informations sur une machine distante</title>
    <HTA:APPLICATION
    APPLICATIONNAME="Login Details"
    BORDER="thin"
    SCROLL="no"
    SINGLEINSTANCE="yes"
    WINDOWSTATE="normal"></head>
     
    <script language="VBScript">
     
    Sub Window_onLoad
    Me.ResizeTo 400,300
    Me.MoveTo ((Screen.Width / 2) - 200),((Screen.Height / 2) - 150)
    End Sub
     
    Sub Default_Buttons
    If Window.Event.KeyCode = 13 Then
    btn_logindetails.Click
    End If
    End Sub
     
    Sub Get_Login_Details
    strComputer = txt_computer.value
    if strComputer = "" Then
    msgbox "Nom de machine ou adresse IP invalide",vbOKOnly,"Saisie incorrecte"
    Exit Sub
    End If
     
    If Ping(strComputer) = False Then
    msgbox "L'ordinateur " & strComputer & " ne répond pas.",vbOkOnly, "Machine introuvable"
    Exit Sub
    End If
     
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
     
    Set colComputer = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
     
    Set colComputerIP = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration")
     
    Set colSystemInfo = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem",,48)
     
    For Each objComputer in colComputer
    UsrNom = "Aucune session en cours"
    If Not IsNull(objComputer.UserName) Then UsrNom = objComputer.UserName
    strUserName = "Utilisateur : " & UsrNom
    strHostName = "Nom machine : " & objComputer.Name
    Next
     
    For Each IPConfig in colComputerIP
    If Not IsNull(IPConfig.IPAddress) Then
    For intIPCount = LBound(IPConfig.IPAddress) _
    to UBound(IPConfig.IPAddress)
    strIPAddress = strIPAddress & "Adresse IP : " & IPConfig.IPAddress(intIPCount) & "~"
    next
    end if
    Next
     
    If Right(strIPAddress, 1) = "~" Then
    strIPAddress = Left(strIPAddress, Len(strIPAddress) - 1)
    End If
    strIPAddress = Replace(strIPAddress, "~", vbCrLf)
     
    For Each objItem in colSystemInfo
    strOS_Caption = "Système : " & objItem.Caption
    strOS_SPVersion = "Version SP : " & objItem.CSDVersion
    strOS_VerNumber = "N° Version : " & objItem.Version
    Next
     
    MsgBox strUserName & vbcrlf & strHostName & vbcrlf & _
    strIPAddress & vbcrlf & strOS_Caption & vbcrlf & _
    strOS_SPVersion & vbcrlf & strOS_VerNumber, vbOKOnly, "Informations"
    End Sub
     
    Function Ping(strComputer)
    Dim objShell, boolCode
    Set objShell = CreateObject("WScript.Shell")
    boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
    If boolCode = 0 Then
    Ping = True
    Else
    Ping = False
    End If
    End Function
    </script>
     
    <body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
    (GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
    <table width='80%' height = '100%' align='center' border='0'><tr height='20%'><td></td></tr>
    <tr height='10%'><td align='center'>Nom machine ou adresse IP :</td></tr
    <tr height='20%'><td align='center'>
    <input type="text" value="Saisie" name="txt_computer" maxlength='15' size='16'>
    </td></tr><tr height='30%'><td align='center'>
    <input type="button" value="Lancer le test" name="btn_logindetails"  onClick="Get_Login_Details">
    </td></tr><tr height='20%'><td></td></tr></table></body>
    Encore merci !
    ++

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Vérouillage de session à distance
    Par splash68 dans le forum C++
    Réponses: 3
    Dernier message: 19/01/2011, 13h42
  2. Récupération d'informations V$SESSION
    Par arnaud_moi dans le forum PL/SQL
    Réponses: 3
    Dernier message: 25/06/2010, 16h36
  3. Enregister des informations de session
    Par BFdotNET dans le forum PHP & Base de données
    Réponses: 11
    Dernier message: 18/07/2008, 12h05
  4. [GWT] Informations de session
    Par groupe dans le forum GWT et Vaadin
    Réponses: 4
    Dernier message: 25/04/2008, 13h06
  5. Réponses: 3
    Dernier message: 15/06/2006, 15h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo