Every wanted to automate the imaging of your mom's XP system? How about that friend that always seems to mess up his computer and you have to reload the OS. Well never fear!! This little script, along with DriveImageXML (it is free by the way), will automatically image that XP machine to the same drive or another drive. You pick. Make sure DriveImageXML is installed and adjust the path if necessary. I use the task scheduler and set this run once a month. You could even modify this script to map a netwrk drive and image it there. Good luck!!
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objNetwork = CreateObject("WScript.Network")
' // Path to the dixml.exe file (Drive Image XML is a free imaging product)
DIXMLPath = """c:\program files\runtime software\driveimage xml\dixml.exe"""
' // Path to where you will be imaging the system to. Cannot us UNC pathnames for this.
oldImagePath = "D:\Backups\"
' // This section assumes that the clock on your PC is somewhat accurate
CurrentYear = Year(Date) & MonthName(Month(Date),true)
' \\ Check to see if the current year directory exists
' \\ -1 = exists 0 = doesn't exist
isFolder = objFSO.FolderExists(oldImagePath & CurrentYear)
if isFolder = 0 then
'wscript.echo "Doesn't Exist"
set makeFolder = objFSO.CreateFolder(oldImagePath & CurrentYear)
end if
' \\ Checking to see if the computer has already been archived once.
' \\ Check to see if the current directory exists
' \\ -1 = exists 0 = doesn't exist
isFolder = objFSO.FolderExists(oldImagePath & CurrentYear)
if isFolder = 0 then
set makeFolder = objFSO.CreateFolder(oldImagePath & CurrentYear & "\" & UCase(computerName))
dirPath = oldImagePath & CurrentYear & "\" & computerName
else
i = 1
dirExists = "no"
Do Until dirExists = "yes"
isFolder = objFSO.FolderExists(oldImagePath & CurrentYear & "\" & computerName & i)
if isFolder = 0 then
set makeFolder = objFSO.CreateFolder(oldImagePath & CurrentYear & "\" & UCase(computerName & i))
dirPath = oldImagePath & CurrentYear & "\" & computerName & i
dirExists = "yes"
else
i = i + 1
end if
Loop
end if
' // This section will open up the drive C image on the local machine to make sure it s good and to let you know that it worked.
objWshShell.Run DIXMLPath & "/bC /s- /v /c /t" & dirPath & "\Drive_C"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.