Bonjour,
j'ai fait un script pour l'installation automatique de l'antivirus suivant le modèle de l'ordinateur "Optiplex" j'installe l'antivirus 1 ou autre exemple "Latitude" ou "Precision" j'installe l'antivirus 2,
Il fonctionne partiellement
Je voudrais le simplifier en faisant un if var = optiplex (install antivirus 1) else (install antivirus 2)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 REM Installation antivirus Call :GetModele Modele ::******************************************************************* :GetModele <Modele> FOR /F "tokens=2 delims==" %%I IN ( 'wmic computersystem get model /format:list 2^>^nul' ) DO FOR /F "delims=" %%A IN ("%%I") DO SET "%1=%%A" ::******************************************************************* SET var=%modele% SET searchVal=Optiplex SET var|FINDSTR /b "var="|FINDSTR /i %searchVal% >nul IF ERRORLEVEL 0 (msiexec.exe /i "C:\Deploy\AntivirusFixe" /q /norestart) ELSE ("C:\Deploy\AntivirusPortable")
mais ça ne fonctionne pas
Je voudrais l'inclure dans le batch suivant
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 wmic computersystem get model set MO = %Model% echo %MO% IF in 'MO^|findstr "optiplex"' do (msiexec.exe /i "Antivirus 1" /q /norestart) ELSE do ("Antivirus 2")
Merci de votre retour
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 REM Paramétrage profil Wifi cmd.exe /C netsh wlan add profile filename=C:\Deploy\MonWifi.xml REM Barre des tâches cmd.exe /C C:\Deploy\TaskBar.cmd REM Modification UAC reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0 /f reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 1 /f reg add "HKEY_USERS\.DEFAULT\Control Panel\Keyboard" /v "InitialKeyboardIndicators" /t REG_SZ /d 2 /f REM Ajout domaine wmic.exe /interactive:off ComputerSystem Where name="%computername%" call JoinDomainOrWorkgroup FJoinOptions=3 Name="MonDomaine" UserName="User" Password="MotDePasse" REM Installation Teamviewer Host msiexec.exe /i "C:\Deploy\TeamViewer_Host.msi" /q CUSTOMCONFIGID=7xsnes3 APITOKEN=monapitoken ASSIGNMENTOPTIONS="--grant-easy-access --group-id Monid" REM Installation antivirus Call :GetModele Modele ::******************************************************************* :GetModele <Modele> FOR /F "tokens=2 delims==" %%I IN ( 'wmic computersystem get model /format:list 2^>^nul' ) DO FOR /F "delims=" %%A IN ("%%I") DO SET "%1=%%A" ::******************************************************************* SET var=%modele% SET searchVal=Optiplex SET var|FINDSTR /b "var="|FINDSTR /i %searchVal% >nul IF var contient optiplex (msiexec.exe /i "antivirus 1" /q /norestart) ELSE ("antivirus 2") REM Suppression dossier Deploy rmdir C:\Deploy /s /q REM Redémarrage dans 30 secondes cmd.exe /C shutdown /r /t 30
Partager