Script d'information sur le disque
Option Explicit
Dim sArg, oFSO, sDriveName, sType
Set oFSO = CreateObject("Scripting.FileSystemObject")
' Obtenir le nom de fichier absolu depuis une ligne de commande, puis obtenir le nom du disque
Rem If Wscript.Arguments.Count < 1 Then Wscript.Quit(1)
If Wscript.Arguments.Count < 1 Then sArg="C:" Else sArg=oFSO.GetAbsolutePathName(Wscript.Arguments(0))
sDriveName=oFSO.GetDriveName(sArg)
' Obtenir les propriétés d'objet et les afficher
With oFSO.GetDrive(sDriveName)
Wscript.Echo "Taille totale du disque (Go) :", .TotalSize / 1024000000
Wscript.Echo "Espace disponible (Go) :", .AvailableSpace / 1024000000
Wscript.Echo "Espace libre (Go) :", .Freespace / 1024000000
Wscript.Echo "Lettre de disque :", .Driveletter
Wscript.Echo "Nom de partage UNC :", .ShareName
Wscript.Echo "Nom de Volume :", .VolumeName
Wscript.Echo "Chemin :", .Path
Wscript.Echo "Numéro de série :", Hex(.SerialNumber)
Wscript.Echo "Système de fichiers :", .FileSystem
Wscript.Echo "Disque prêt :", CBool(.IsReady)
Select Case .DriveType
Case 1: sType = "Amovible"
Case 2: sType = "Fixe"
Case 3: sType = "Réseau"
Case 4: sType = "CD-ROM"
Case 5: sType = "Disque RAM"
Case else sType = "Inconnu"
End Select
Wscript.Echo "Type de disque :", sType
End With
Set oFSO=Nothing
Impression avec Word
Dim DocToPrint, oWord, oDoc
DocToPrint = "C:\tmp\test.txt"
Set oWord = CreateObject("Word.Application")
Set oWordActiveDoc = oWord.Documents.Open("" & DocToPrint)
oWordActiveDoc.PrintOut
MsgBox "Impression du log terminée."
oWordActiveDoc.Close
oWord.Quit
Set oWord = Nothing
Script de test que j'ai fait quand j'étais petit
' ----------------------------------------------------------------------------------------------
' ¦ Script visant à réchauffer le coeur des gens en leur fouttant une image de Joyeux Noel !!! ¦
' ----------------------------------------------------------------------------------------------
Option Explicit
Dim objFich, Jour, Mois, Annee, Computername, objReseau, objShell, AncienneImage, Noel, ManipFich, BMPApres
const BMPlocal="c:\winnt\noel.bmp", BMPServeur="\\tcsgroup.ch\Netlogon\noel.bmp", BackupImage="c:\winnt\oldbmp.txt"
' --------------------------------
' Conditions de machines pour Test
' --------------------------------
Set objReseau = CreateObject("Wscript.Network")
Computername = objReseau.Computername
Computername = Ucase(Computername)
If Computername<>"YITEC328" Then WScript.Quit
' ---------------------------------------------
' Conditions de date pour l'exécution du script
' ---------------------------------------------
' On peut faire beaucoup mieux avec DATEDIFF (Cela dit, c'est deja pas mal...)
Jour = left(Date,2)
Mois = Mid(Date,4,2)
Annee = Right(Date,2)
If Mois="12" And Jour<"20" and Annee="01" Then
Noel="Avant"
End If
If Mois="12" And Jour>"19" and Annee="01" Then
Noel="Pendant"
End If
If Annee="02" Then
Noel="Apres"
End If
' ---------------------------
' Copie de l'image dans Winnt
' ---------------------------
Set ObjFich = CreateObject("Scripting.FileSystemObject")
If objFich.FileExists(BMPLocal) Then
Else
objFich.CopyFile(BMPServeur,BMPLocal)
End If
' ------------------------------------------
' Exportation de la clef original AVANT Noel
' ------------------------------------------
If Noel="Avant" then
If objFich.FileExists(BackupImage) Then
Else
Set objShell = CreateObject("Wscript.Shell")
AncienneImage=objShell.RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper")
Set ManipFich = objfich.OpenTextFile(BackupImage, 2, True) ' 2 = Ecrire
ManipFich.Write """Wallpaper""=""" & AncienneImage & """"
ManipFich.Close
End If
End If
' ------------------------------------------
' Modification de la clef PENDANT Noel
' ------------------------------------------
If Noel="Pendant" Then objShell.RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper",BMPLocal)
' ------------------------------------------
' Importation de la clef APRES Noel
' ------------------------------------------
If Noel="Apres" Then
BMPApres=objShell.RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper")
If BMPApres<>BMPlocal then
Set ManipFich = objfich.OpenTextFile(BackupImage, 1, True) ' 1 = Lire
ManipFich.read AncienneImage
ManipFich.Close
objShell.RegWrite("HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper",AncienneImage)
End if
end if