spark.ps1
4.61 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
New-Item $env:TEMP\spark.properties -type file -force -value "#Spark Settings
#Fri Jul 28 21:20:52 BRT 2017
username=SeuSiape
ccAdvancedConfig=true
hostAndPort=false
proxyEnabled=false
windowTakesFocus=false
useVersionAsResource=false
compressionOn=false
notifyOnOffline=false
disableAsteriskToasterPopup=false
checkForBeta=false
trustStorePassword=
videoDevice=imgstreaming\:0
audioDevice=audiosilence\:
SelectedCodecs=ALAW/rtp^ULAW/rtp^gsm/rtp^g723/rtp^
xmppHost=
isMucRandomColors=true
isMucHighNameOn=false
isMucHighTextOn=false
AvailableCodecs=
resource=Spark
SystemTrayNotificationEnabled=false
showOfflineUsers=false
loginAnonymously=false
server=chat.cefetes.br
useHostnameAsResource=false
showHistory=true
DisableHostnameVerification=true
pkiEnabled=false
debuggerEnabled=false
notifyOnOnline=false
showPrevHistory=true
DisplayTime=1000
ccInvisibleLogin=true
ssoEnabled=false
toasterPopup=false
pkiStore=JKS
xmppPort=5222
proxyPassword=
isMucHighToastOn=false
buzzEnabled=true
stunFallbackHost=
HISTORY_SORT_DATEASC=true
loginAsInvisibleEnabled=false
isShowingRoleIcons=false
timeFormat=HH\:mm
protocol=SOCKS
lastUpdateCheck=1501287514968
showTypingNotification=false
proxyUsername=
showEmptyGroups=false
timeout=10
ccAnonymousLogin=true
AcceptAllCertificates=true
chatNotificationOn=true
offlineGroupVisible=true
password
jksPath=
autoAcceptMucInvite=false
audioSystem=wasapi
timeDisplayed=true
ccAccountsReg=true
ccHostNameChange=true
useAdHocRoom=true
tabsOnTop=true
passwordSaved=true
ccPswdAutologin=true
defaultChatLengthTimeout=15
isShowJoinLeaveMessagesOn=true
autoLoginEnabled=true
stunFallbackPort=3478
sslEnabled=false
trustStorePath=
playbackDevice=wasapi\:{3.0.0.00000002}.{6C26BA7D-F0B2-4225-B422-8168C5261E45}
ssoMethod=file
saslGssapiSmack3compat=false
" | out-null
######
$date = Get-Date
$App = "Spark"
$Version = "2.8.3"
$AppExe = "C:\Program Files (x86)\Spark\Spark.exe" #executavel do aplicativo após instalação
$AppDate = "2017-01-29" #data do aplicativo, para verificar a atualização
$SourceFile = "\\gr-fs\install\Padrao\Aplicativos\spark_2_8_3_online.exe" #local do installer na rede
$spark_properties = "$env:TEMP\spark.properties"
$FileExe = "$env:TEMP\spark_2_8_3.exe" #local do installer na maquina
$Parameters = "-q" #parametros de instalação
$Process = "Installer" #nome do processo do installer
$LogFile = "$env:TEMP_$env:computername.txt" #arquivo de log de instalação e atualização
# Função para a instalação do aplicativo
#
function instalar ($Arg1,$Arg2)
{
if (!(test-path $FileExe)) #Arquivo de instalação local encontrado?
{
if (test-path "$env:TEMP\spark*.exe") #remove arquivos de instalação antigos se existirem
{Get-ChildItem "$env:TEMP\spark_*.exe"|ForEach-Object { Remove-Item $_ }
}
Copy-Item -Path $SourceFile -Destination $FileExe | out-null #copia o arquivo de instalação novo
start-sleep 10
}
$proc = Get-Process
if ($proc.name -contains "Spark") {Stop-Process -Name Spark -Force -Confirm}
& $Arg1 + $Arg2
start-sleep 20 #aguarda o processo de instalação iniciar
Do { #aguarda a finalização do processo
start-sleep 10
$proc = Get-Process
} While ($proc.name -contains $Process)
$date = Get-Date
Add-Content -Path $LogFile -Value ("O $App versão $Version foi instalado em $date")
# Substituição do arquivo de configuração para todos os usuários da maquina
$Users = Get-ChildItem -Directory -Path C:\Users
ForEach ($User in $Users){
$dir = "C:\Users\" + $User.name + "\AppData\Roaming\Spark"
if (!(test-path $dir)) {mkdir $dir}
$file = $dir + "\spark.properties"
Copy-Item -Path $spark_properties -Destination $file | out-null
}
}
# Inicio da rotina de verificação da instalação do aplicativo
#
if (test-path $AppExe) #Aplicativo Instalado?
{
if ((Get-ItemPropertyValue -Name lastwritetime -Path $AppExe) -gt (get-date $AppDate))
{ instalar $FileExe $Parameters}
}
else
{
instalar $FileExe $Parameters
}
# Substituição do arquivo de configuração padrão para os novos usuários da maquina
$dir = "C:\Users\Default\AppData\Roaming\Spark"
if (!(test-path $dir)) {mkdir $dir}
$file = $dir + "\spark.properties"
Copy-Item -Path $spark_properties -Destination $file | out-null