中国网络-ITPro俱乐部's Archiver

跃跃领舞 发表于 2007-7-5 17:21

SMS脚本:客户端安装脚本

该贴转自合作社区——[url=http://www.systemcenter.com.cn/bbs/]SC中文社区[/url],请大家支持国内最专业的SystemCenter中文社区!

'==========================================================================
'
' VBScript Source File -- Created with SAPIEN
'
' NAME: SMS Client Install script
'
' AUTHOR: Santos Martinez
' DATE  : 5/3/2007
'
' COMMENT: Version 0.1
' This Script is presented as is
'==========================================================================
sWrite_Log_File "smsclientinstall.log","**Starting**"
On Error Resume Next
Dim FSO, WSHShell, SysFolder, ClientInst, objNetwork
Dim colSystemEnvVars, computerName

'Set up out object environments
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = Wscript.CreateObject("Wscript.Network")
Set colSystemEnvVars = WSHshell.Environment("System")
'Get Computer Name for logging
'computerName = objNetwork.ComputerName
'Read SYSTEM32 folder location into variable
Set SysFolder = fso.GetSpecialFolder(1)
'Check to see if SMS2003 Client executable exists
If FSO.FileExists(SysFolder & "\ccm\ccmexec.exe") Then
'Msgbox "Client Already Installed"
sWrite_Log_File "smsclientinstall.log","**Client Already Installed**"
'quit
WScript.Quit(0)
end if
'Msgbox "Installing Client"
sWrite_Log_File "smsclientinstall.log","**Installing Client**"
'Launch the SMS2003 client installation, CAPINST.exe, don't wait for it to exit
WSHShell.Run "[url=]\\yoursmssrver\Client\ccmsetup.exe[/url] /service SMSSITECODE=[color=deepskyblue]XXX1[/color], False
sWrite_Log_File "smsclientinstall.log","**Client Installation KickUp**"
'Quit
WScript.Quit(0)
Sub sWrite_Log_File(FileName,Text)
Dim objFileSystem, objFile, WshShell, WshSysEnv
Const ForReading = 1, ForWriting = 2, ForAppending = 8
  
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("SYSTEM")
Set objFileSystem=CreateObject("scripting.filesystemobject")
Set objFile=objFileSystem.OpenTextFile (WshShell.ExpandEnvironmentStrings ("%WINDIR%") &"\" & FileName,ForAppending,true)
objFile.write Date & " " & Time & " " & Text & vbcrlf
objFile.Close

Set objFile=Nothing
Set WshShell=Nothing
Set objFileSystem=Nothing

end Sub

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.