Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1285 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Besoin d'aide pour modifier un .vbs svp

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Besoin d'aide pour modifier un .vbs svp

n°801789
kayasax
Posté le 21-07-2004 à 13:14:06  profilanswer
 

Bonjour,
je n'y conais absolument rien en vbs, par contre j'ai récupérer un petit script qui me plait bien (recupere la date de derniere connexion d'un utilisateur), mais je voudrais le modifier pour qu'il écrive le résultat dans un fichier au lieu qu'il m'ouvre une fenetre par utilisateur .
Si il y a une ame charitable de passage...
Merci


On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2" )
Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile" )
For Each objItem in colItems
    dtmWMIDate = objItem.LastLogon
    strReturn = WMIDateStringToDate(dtmWMIDate)
    Wscript.Echo "Name: " & objItem.Name & " Last Logon: " & strReturn
     
Next
Function WMIDateStringToDate(dtmWMIDate)
    If Not IsNull(dtmWMIDate) Then
    WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _
         Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
             & " " & Mid (dtmWMIDate, 9, 2) & ":" & _
                 Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate, _
                     13, 2))
    End If
End Function


 
PS : ce script ne récupère que les accès sur un ordi, y a t'il moyens de récupére les accès pour tous les postes du domaine ?


Message édité par kayasax le 21-07-2004 à 13:18:16
mood
Publicité
Posté le 21-07-2004 à 13:14:06  profilanswer
 

n°803936
k2t
Posté le 23-07-2004 à 08:13:24  profilanswer
 

Code :
  1. On Error Resume Next
  2. strComputer = "."
  3. Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2" )
  4. Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile" )



Set FSys = CreateObject("Scripting.FileSystemObject" )
Set F = fso.CreateTextFile("c:\temp\", "STATS-LOGON.TXT", ForWriting, True)

Code :
  1. For Each objItem in colItems
  2.    dtmWMIDate = objItem.LastLogon
  3.    strReturn = WMIDateStringToDate(dtmWMIDate)


   F.Write "Name: " & objItem.Name & " Last Logon: " & strReturn

Code :
  1. Next
  2. Function WMIDateStringToDate(dtmWMIDate)
  3.    If Not IsNull(dtmWMIDate) Then
  4.    WMIDateStringToDate = CDate(Mid(dtmWMIDate, 5, 2) & "/" & _
  5.         Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
  6.             & " " & Mid (dtmWMIDate, 9, 2) & ":" & _
  7.                 Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate, _
  8.                     13, 2))
  9.    End If
  10. End Function


 
 
voila je t'ai rajouter du code en gras, ce sont les lignes qui te permetront d'insérer dans un fichier.
 
ca devrait fonctionner (a tester !!!).
 
bonne journee

n°804648
kayasax
Posté le 23-07-2004 à 15:51:58  profilanswer
 

ok merci


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  Besoin d'aide pour modifier un .vbs svp

 

Sujets relatifs
Besoin d'aide Vba lien entre excell et word[javascript] modifier un pop up après ouverture
[SQL] cmt supprimer/modifier un enregistrement d'un table ?[JSP] Aide pour projet de fin d'année
Aide sur InstallShield 2.0[résolu] Aide pour webmaster debutant
L'aide automatique et la compilationaide pour le flash
Besoin d'aide 
Plus de sujets relatifs à : Besoin d'aide pour modifier un .vbs svp


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)