un script vbs qui fait tourner une boucle pour faire des snapshots de VM
le script est appelé par un .bat qui lui passe les paramètres
Option Explicit
Dim WshShell, APP, APP_SNAPSHOT, IPFROMBAT, USERFROMBAT, PASSFROMBAT, LOGFROMBAT,ArgObj
Set ArgObj = WScript.Arguments
IPFROMBAT = ArgObj(0)
USERFROMBAT = ArgObj(1)
PASSFROMBAT = ArgObj(2)
LOGFROMBAT = ArgObj(3)
Set WshShell = WScript.CreateObject("WScript.Shell")
APP = """C:\Program Files\VMware\VMware VIX\vmrun.exe""" & " -T server -h " & IPFROMBAT & "/sdk -u " & USERFROMBAT & " -p " & PASSFROMBAT & " "
APP_SNAPSHOT = " -T server -h " & IPFROMBAT & "/sdk -u " & USERFROMBAT & " -p " & PASSFROMBAT &" snapshot ""__VMNAME__"""
Dim Fsys, myLog
Set Fsys = CreateObject("Scripting.FileSystemObject")
Set myLog = Fsys.OpenTextFile(LOGFROMBAT & "log_snapshot.txt",8, false)
myLog.WriteLine "--------------------------------------------------------------------"
Dim lstVM, objStdOut
Set lstVM = WshShell.Exec (APP & """list""")
Set objStdOut = lstVM.StdOut
myLog.WriteLine Date & " " & Time & " Exécution commande LIST"
Dim strParamList, strLine, res
strLine = objStdOut.ReadLine
While Not objStdOut.AtEndOfStream
strLine = objStdOut.ReadLine
strParamList = Replace(APP_SNAPSHOT, "__VMNAME__", strLine )
res = WshShell.Run (APP & strParamList, 0, true)
myLog.WriteLine Date & " " & Time & " Exécution commande SNAPSHOT " & strLine & " Résultat : " & res
Wend
myLog.WriteLine Date & " " & Time & " Fin de script"
myLog.Close
GPO Active Directory
GPO Active Directory
faut pas que le script soit trop gros car on est pas des dev, en plus je pige rien xD
GPO Active Directory
moi non plus c'est un collègue développeur qui me l'a fait
mais au moins tu vois la construction d'une boucle while/wend

mais au moins tu vois la construction d'une boucle while/wend
GPO Active Directory
je verrais ca ce soir/demain quand j'aurais fini toutes mes fiches