-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstallAgentAsSYSTEM.bat
85 lines (72 loc) · 3.06 KB
/
InstallAgentAsSYSTEM.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
@ECHO OFF
setLocal ENABLEDELAYEDEXPANSION
SET VRAHOST=<vra app>.<fqdn>
SET VRAMGR=<vra mgr>.<fqdn>
SET APPCERTPRINT=<app cert thumbprint>
SET MGRCERTPRINT=<mgr cert thumbprint>
CLS
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ ³
ECHO ³ ³
ECHO ³ PREPARE: vRA Agent with SYSTEM ³
ECHO ³ ³
ECHO ³ ³
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
rmdir /s /q !SystemDrive!\hold >nul 2>nul & verify >nul
ECHO Removing any vRA agents installed...
:REMOVEAGENTSVC
net stop vcacguestagentservice >nul 2>nul
sc delete vcacguestagentservice >nul
:REMOVEBOOTSTRAPSVC
net stop vRASoftwareAgentBootstrap >nul 2>nul
sc delete vRASoftwareAgentBootstrap >nul
rmdir /s /q !SystemDrive!\opt >nul 2>nul & verify >nul
timeout 3
:REMOVEACCOUNT
ECHO Cleaning up Darwin's profile folder(s) if exist...
powershell -noprofile -executionPolicy bypass -File "%~dp0scripts\Cleanup-Profile.ps1" -Name "Darwin"
:INSTALLAGENT
CLS
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ ³
ECHO ³ ³
ECHO ³ READY: vRA Agent with SYSTEM ³
ECHO ³ ³
ECHO ³ ³
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ECHO Installing vRA Agent...
powershell.exe -noprofile -executionPolicy bypass -file "%~dp0scripts\prepare_vra_template.ps1" -ApplianceHost !VRAHOST! -ManagerServiceHost !VRAMGR! -CloudProvider vSphere -SoftwareLocalSystem -ManagerFingerprint !MGRCERTPRINT! -ApplianceFingerprint !APPCERTPRINT! -Noninteractive -NoWindowsCheck
If !ERRORLEVEL! NEQ 0 GOTO ERROR
GOTO SCRIPTS
:SCRIPTS
REM Adding custom scripts...
mkdir !SystemDrive!\VRMGuestAgent\scripts
copy %~dp0scripts\UserandGroupControl.vbs c:\VRMGuestAgent\scripts\UserandGroupControl.vbs
If !ERRORLEVEL! NEQ 0 GOTO ERROR
GOTO SUCCESS
:ERROR
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ ³
ECHO ³ ERROR: vRA Agent install failed ³
ECHO ³ ³
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ECHO Agent was unable to install. Agent may be already installed, Follow README.txt and uninstalling the agent and reboot.
pause
GOTO EOF
:SUCCESS
ECHO ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
ECHO ³ ³
ECHO ³ SUCCESS: vRA Agent installed ³
ECHO ³ ³
ECHO ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
ECHO Install Complete. Shutdown and convert to template
Choice /T 30 /D Y /M "Would you like to shutdown now"
IF !ERRORLEVEL! EQU 1 GOTO SHUTDOWN
IF !ERRORLEVEL! EQU 2 GOTO EOF
:SHUTDOWN
SET InstallDIR=!cd!
REM Removing the script folder (!InstallDIR!) and preparing to shutdown
cd\
cmd /c "Taskkill /f /im explorer.exe && start explorer.exe" >nul 2>nul & verify >nul
start /b "" cmd /c rmdir /s /q "!InstallDIR!" && Shutdown /s /t 05 /c "Shutting down system..." >nul 2>nul & verify >nul
:EOF