DC - 静默安装代理脚本

DC - 静默安装代理脚本

一、bat 脚本

@ECHO OFF
@cd /d "%~dp0"
start /wait msiexec /i DesktopCentralAgent.msi TRANSFORMS="DesktopCentralAgent.mst" ENABLESILENT=yes REBOOT=ReallySuppress /qn INSTALLSOURCE=Manual SERVER_ROOT_CRT="%cd%\DMRootCA-Server.crt" DS_ROOT_CRT="%cd%\DMRootCA.crt" /lv Agentinstalllog.txt


二、vbs 脚本

'Script to  Install Desktop Central Agent
'==========================================

'To install agent with the share path given as argument
'===================================================================

On Error Resume Next


Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshSysEnv = WshShell.Environment("Process")
DrivePath = WshShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")
checkOSArch = WshShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")


if Err Then
Err.Clear
regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\AdventNet\DesktopCentral\DCAgent\"
else
if checkOSArch = "x86" Then
regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\AdventNet\DesktopCentral\DCAgent\"
else
regkey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\AdventNet\DesktopCentral\DCAgent\"
End IF
End If


' Get Location and arguments of the script
'currdir = WSCript.Arguments.Item(0)
currdir = WshShell.currentDirectory
agentVersion = WshShell.RegRead(regkey&"DCAgentVersion")

if Err Then
Err.Clear
msiFile = WSCript.Arguments.Item(0)
mstFile = WSCript.Arguments.Item(1)
WshShell.Run "msiexec.exe /i """&currdir&"\"&msiFile&"""  TRANSFORMS="""&mstFile&""" ENABLESILENT=yes REBOOT=ReallySuppress /qn MSIRESTARTMANAGERCONTROL=Disable INSTALLSOURCE=GPO /lv "&DrivePath&"\dcagentInstaller.log",0,True
End If
1. 脚本文件命名为 InstallAgent.vbs。将脚本和 msi、mst 文件存放在同一路径下。
2. 以管理员身份运行命令:WScript InstallAgent.vbs DesktopCentralAgent.msi DesktopCentralAgent.mst