To Tatoo the deployed Windows 7
(This tatoo will be used by SCCM hardware inventory)
Const Version = 1.0
Dim oShell, osdV4, WshSysEnv
Set oShell = CreateObject ("WSCript.shell")
Set osdV4 = CreateObject("Microsoft.SMS.TSEnvironment")
Set WshSysEnv = oShell.Environment("SYSTEM")
Dim PathNameLog, KeyPath
PathNameLog = osdV4("_SMSTSLogPath") & "\DesktopTatoo.log"
LogTextToFile("--------------------------------------------------")
LogTextToFile "Start Version " & Version
LogTextToFile("Starting ...")
'------------------------------------------------------
KeyPath = "HKLM\Software\Corporate"
Dim MasterName, DateInstall, TSVersion, TSName
TSName = osdV4("_SMSTSPackageName")
MasterName = osdV4("ERAMETMasterName")
TSVersion = osdV4("ERAMETMasterVersion")
DateInstall = GetCurrentWMIDate
LogTextToFile("Set MasterName = " & MasterName)
LogTextToFile("Set Version = " & TSVersion)
LogTextToFile("Set DateInstall = " & DateInstall)
LogTextToFile("Set TSName = " & TSName)
oShell.RegWrite KeyPath & "\Master\" & MasterName & "\Master",MasterName, "REG_SZ"
oShell.RegWrite KeyPath & "\Master\" & MasterName & "\Version",TSVersion, "REG_SZ"
oShell.RegWrite KeyPath & "\Master\" & MasterName & "\TSName",TSName, "REG_SZ"
oShell.RegWrite KeyPath & "\Master\" & MasterName & "\InstallDate",DateInstall, "REG_SZ"
Set oShell = Nothing
function LogTextToFile(strTextToLog)
Dim objFileSystemObjectForLogfileAccess, objFile, objLogFile2,objLogFile , n
Dim strFilenameWithoutExtension
const intMaxFileSize = 2097152
strFilenameWithoutExtension= left(PathNameLog ,len(PathNameLog)-4)
On Error Resume Next
Set objFileSystemObjectForLogfileAccess = CreateObject("Scripting.FileSystemObject")
n = -1
Set objFile = objFileSystemObjectForLogfileAccess.getfile(strFilenameWithoutExtension & ".log")
If objFile.Size > intMaxFileSize Then
Set objLogFile2 = objFileSystemObjectForLogfileAccess.getfile(strFilenameWithoutExtension & ".lo_")
objLogFile2.Delete
objFile.name = left(objFile.name, len(objFile.name)-1) & "_"
objFile.close
End If
Set objLogFile = objFileSystemObjectForLogfileAccess.opentextfile(strFilenameWithoutExtension & ".log", 8, True)
objLogFile.writeline Date & " - " & Time & " - """ & strTextToLog & """"
objLogFile.Close
Set objFile = Nothing
Set objLogFile2 = Nothing
set objLogFile = nothing
End Function
function GetCurrentWMIDate()
'GetWMIDate=cstr(year(cur_date)) & cstr(month(cur_date)) & cstr(day(cur_date)) & cstr(replace(time,":","")) & ".000000+***"
Dim HourFormat,MinuteFormat,SecondFormat, YearFormat, Monthformat, dayformat
YearFormat = cstr(year(now))
Monthformat = cstr(month(now))
dayformat = cstr(day(now))
HourFormat = cstr(hour(time))
MinuteFormat = cstr(minute(time))
SecondFormat = cstr(second(time))
if len(Monthformat)=1 Then
Monthformat = "0" & Monthformat
end If
if len(dayformat)=1 Then
dayformat = "0" & dayformat
end If
if len(HourFormat)=1 then
HourFormat = "0" & HourFormat
end If
if len(MinuteFormat)=1 then
MinuteFormat = "0" & MinuteFormat
end If
if len(SecondFormat)=1 then
SecondFormat = "0" & SecondFormat
end If
GetCurrentWMIDate = YearFormat & Monthformat & dayformat & HourFormat & MinuteFormat & SecondFormat & ".000000+***"
End Function
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article