widsnet.com
20Apr/170

Syncronize time in a task sequence

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
Set objOSDEnv = CreateObject("Microsoft.SMS.TSEnvironment")
sLogPath = objOSDEnv("_SMSTSLogPath")

sLogFileName = Replace(WScript.ScriptName, ".vbs", ".log")
logThis "LogFile: " & sLogPath & "\" & sLogFileName

sUser = objOSDEnv("_SMSTSReserved1-000")
sPassword = objOSDEnv("_SMSTSReserved2-000")

logThis "%comspec% /c NET USE \\SERVER\IPC$ """ & "<password>" & """ /USER:" & sUser
Set oExec = oShell.Exec("%comspec% /c ""NET USE \\SERVER\IPC$ " & sPassword & " /USER:" & sUser & """")
logThis oExec.StdOut.ReadAll
logThis oExec.StdErr.ReadAll

logThis "%comspec% /c NET TIME \\SERVER /SET /Y"
Set oExec = oShell.Exec("%comspec% /c NET TIME \\SERVER /SET /Y")
logThis oExec.StdOut.ReadAll
If oExec.StdErr.ReadAll <> "" Then
	logThis oExec.StdErr.ReadAll
	wscript.quit(3912)
End If


Sub logThis(strText)
	'Create (if it doesn't exist) and open the logFile for appending
	Set oLogFile = objFSO.OpenTextFile(sLogPath & "\" & sLogFileName, ForAppending, True, 0)
	oLogFile.WriteLine(strText)
	oLogFile.Close	
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.