Je vous dépose rapidement un VBS que je viens de déployer chez un de mes clients, inspiré des différents scripts VBS que j'ai pu trouver sur le site et sur la forge.
Il permet d'installer FusionInventory sur les machines sur lesquelles il n'est pas encore installé, et mettre à jour les versions 2.2.x en ajoutant le paramètre "/execmode=none" nécessaire quand la version 2.2 est déjà présente.
Il me reste encore à prévoir le cas où la version 2.1 est présente ; il faut alors arrêter le service, désinstaller la version 2.1, et installer la version 2.2 (si quelqu'un l'écrit avant moi, je suis preneur !).
Le script ci-dessous est sans danger; il ne fait qu'afficher des boîtes de dialogue, à vous de le "réarmer" ;-)
Chez mon client, je l'ai placé comme script de démarrage d'une stratégie "ordinateur" du domaine Active Directory, il fonctionne bien.
Marc
Code: Option Explicit
On Error Resume Next
Dim AvailableVersion, InstalledVersion, FusionArguments, UpdateArguments, FusionSetupExe, WshShell, OSType, InstallCommand, UpdateCommand, InstalledKey
'
' User settings
'
AvailableVersion = "2.2.7-1"
FusionArguments = "/S /tag=MyTag /server=http://server/glpi/plugins/fusioninventory/ /rpc-trust-localhost /runnow"
UpdateArguments = "/execmode=none"
FusionSetupExe = "\\server\netlogon\fusioninventory\fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
'
'DO NOT EDIT BELOW
'
InstallCommand = FusionSetupExe & " " & FusionArguments
UpdateCommand = InstallCommand & " " & UpdateArguments
Set WshShell = Wscript.CreateObject("Wscript.shell")
' Get OS Type, 32 or 64 bit
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
' Extract installed version from registry
if (OsType = "x86") then
InstalledKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
else
InstalledKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
end if
' Install FusionInventory if not yet installed
' Update FusionInventory if available version is different from installed one
InstalledVersion = WshShell.RegRead(InstalledKey)
if InstalledVersion = "" then
Wscript.Echo "FusionInventory not installed, installing version " & AvailableVersion
Wscript.Echo "Running command: " & InstallCommand
'WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True
elseif InstalledVersion <> AvailableVersion then
Wscript.Echo "Installed version: " & InstalledVersion & " - New version available: " & AvailableVersion
Wscript.Echo "Running command: " & UpdateCommand
'WshShell.Run "CMD.EXE /C """ & UpdateCommand & """",0,True
else
Wscript.Echo "Current version " & InstalledVersion & " is up to date"
end if
GLPI 9.4.5 - Fusioninventory for GLPI 9.4+2.4 - Fusioninventory Agent 2.5.2
Salut,
Je l'ai importé dans le site, avec une notice en bas de cette page :
http://www.fusioninventory.org/documenta...e_install/
Je pense que tu peux continuer à le modifier toi même à cet endroit.
Bonne soirée
Super, c'est utile ça, merci ZenAdm
GLPI 0.83.7
Fusioninventory 0.83+2.1
Agent v2.1.14
Et voici la version 2, avec plus de commentaires et la mise à jour depuis la version 2.1 vers la version 2.2.
Dites-moi ce que vous en pensez et comment on peut encore l'améliorer.
Code: '
' FusionInventory-Deploy.vbs
'
' Use this script to automatically
' - install FusionInventory-Agent
' - upgrade from version 2.1 to 2.2
' - update version 2.2.x to 2.2.y
'
' You can run this script manually or use it as a startup script in a computer policy in an Active Directoy forest
'
' Just put the path to fusioninventory-agent_windows-i386_2.2.x.exe in the "FusionSetupExe" variable
'
' Version : 2.0 - 2012-11-26
'
' Author : Marc Caissial <contact@zenitique.fr>
'
' My thanks to the authors of the "fusioninventory.vbs" script on the documentation page
' and to Tomas Abad <tabad@sescam.jccm.es> for his Resources kit for massive and unattended tasks
' that I found on the FusionInventory Forge, and that I used in my upgrade part
'
'
Option Explicit
On Error Resume Next
Dim AvailableVersion, InstalledVersion, FusionArguments, UpdateArguments, FusionSetupExe, WshShell, OSType, InstallCommand, UpdateCommand, StopSvcCommand, StartSvcCommand, UninstallCommand, InstalledKey, UninstallKey
'
' USER SETTINGS
'
AvailableVersion = "2.2.6-1"
FusionArguments = "/S /tag=Mytag /server=http://server/glpi/plugins/fusioninventory/ /rpc-trust-localhost /runnow"
UpdateArguments = "/execmode=none"
FusionSetupExe = "\\server\netlogon\fusioninventory\fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
'
' DO NOT EDIT BELOW
'
InstallCommand = FusionSetupExe & " " & FusionArguments
UpdateCommand = InstallCommand & " " & UpdateArguments
StopSvcCommand = "SC STOP ""FusionInventory-Agent"""
StartSvcCommand = "SC START ""FusionInventory-Agent"""
Set WshShell = Wscript.CreateObject("Wscript.shell")
' Get OS Type, 32 or 64 bit
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
' Extract installed version & uninstall command from registry
if (OsType = "x86") then
InstalledKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
UninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
else
InstalledKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
UninstallKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
end if
' Install FusionInventory-Agent if not yet installed
' If migrating from 2.1 to 2.2, first uninstall 2.1, then install 2.2
' Update FusionInventory if available version is newer than installed one
InstalledVersion = WshShell.RegRead(InstalledKey)
UninstallCommand = """" & WshShell.RegRead(UninstallKey) & """ /S"
' FusionInventory-Agent not yet installed, so install it
if InstalledVersion = "" then
'Wscript.Echo "FusionInventory-Agent not installed, installing v. " & AvailableVersion
'Wscript.Echo "Running command: " & InstallCommand
WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True
' Upgrade from version 2.1 to version 2.2
' Must uninstall version 2.1 first, then install version 2.2
elseif InstalledVersion < "2.2" and AvailableVersion > "2.2" then
'Wscript.Echo "Uninstalling FusionInventory-Agent v. " & InstalledVersion & " & installing v. " & AvailableVersion
'Wscript.Echo "Running commands:" & vbCrLf & " " & StopSvcCommand & vbCrLf & " " & UninstallCommand & vbCrLf & " " & InstallCommand
' Stop the FusioInventory-Agent service
WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
' Uninstal the agent
WshShell.Run "CMD.EXE /C """ & Uninstallcommand & """",0,True
' Wait 30 seconds
WScript.Sleep (30 * 1000)
' Install new version of the agent
WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True
' Update from version 2.2.x to version 2.2.y if y > x, then restart service
elseif InstalledVersion < AvailableVersion then
'Wscript.Echo "Installed version: " & InstalledVersion & vbCrLf & "New version available: " & AvailableVersion
'Wscript.Echo "Running command: " & UpdateCommand
WshShell.Run "CMD.EXE /C """ & UpdateCommand & """",0,True
' Stop the FusioInventory-Agent servive
WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
' Start the FusioInventory-Agent servive
WshShell.Run "CMD.EXE /C """ & StartSvcCommand & """",0,True
else
'Wscript.Echo "Current version " & InstalledVersion & " is up to date"
end if
GLPI 9.4.5 - Fusioninventory for GLPI 9.4+2.4 - Fusioninventory Agent 2.5.2
Il faudrait surtout que le script soit à endroit plus logique =). Tu penses quoi d'un projet sur la forge ?
Waouh ! Pourquoi pas, même si je pense qu'il n'évoluera plus beaucoup maintenant qu'il répond à mes problématiques, surtout si on veut le garder simple et lisible.
GLPI 9.4.5 - Fusioninventory for GLPI 9.4+2.4 - Fusioninventory Agent 2.5.2
2012-12-13, 10:34:19
(This post was last modified: 2012-12-13, 11:02:31 by lee.)
La version Alternative
merci pour le script mais pour le faire fonctionner chez moi
il a fallu que je rajoute 2 fois "end if" à la fin ..
pour correspondre au nombre de "if"
La version finale il manque le TAG
Merci
GLPI 0.90.5/ Plugins Fusion : 090+1.4 / Agent : 2.3.18 < Serveur Centos 64 Bits>
Après réflexion avec Tomas Abad, ce script devrait être intégré directement dans le dépôt du future installer.
Je vous propose donc d'ouvrir une feature request avec le fichier pour qu'il l'ajoute :
http://forge.fusioninventory.org/project...ler/issues
En attendant une intégration plus complète au nouvel installeur, et sa mise à jour sur la page dédiée de la forge (merci d'avance Goneri ;-), voici la dernière mise à jour de mon script.
Je l'utilise depuis ces dernières semaines chez mes clients pour mettre à jour très rapidement les agents, soit à la main en lançant le script sur les postes, soit via une GPO ordinateur.
Ce script installe l'agent, ou le met à jour automatiquement depuis la version 2.1.x ou 2.2.x, et relance le service si besoin.
Pour rendre le script silencieux, il faut commenter les lignes "Wscript.Echo".
Pour installer l'agent depuis une clef USB, il suffit d'avoir l'agent et le VBS dans le même dossier et de supprimer le chemin réseau dans la ligne FusionSetupExe, pour ne garder que:
Code: FusionSetupExe = "fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
Bonne lecture et bonne utilisation, merci d'avance pour vos retours,
Marc
Code: '
' FusionInventory-Deploy.vbs
'
' Use this script to automatically
' - install FusionInventory-Agent
' - upgrade from version 2.1 to 2.2
' - update version 2.2.x to 2.2.y
'
' You can run this script manually or use it as a startup script in a computer policy in an Active Directoy forest
'
' Just put the path to fusioninventory-agent_windows-i386_2.2.x.exe in the "FusionSetupExe" variable
'
' Version : 2.1 - 2012-12-20
'
' Author : Marc Caissial <contact@zenitique.fr>
'
' My thanks to the authors of the "fusioninventory.vbs" script on the documentation page
' and to Tomas Abad <tabad@sescam.jccm.es> for his Resources kit for massive and unattended tasks
' that I found on the FusionInventory Forge, and that I used in my upgrade part
'
'
Option Explicit
On Error Resume Next
Dim AvailableVersion, InstalledVersion, FusionArguments, UpdateArguments, FusionSetupExe, WshShell, OSType, InstallCommand, UpdateCommand, StopSvcCommand, StartSvcCommand, UninstallCommand, InstalledKey, UninstallKey
'
' USER SETTINGS
'
AvailableVersion = "2.2.7-2"
FusionArguments = "/S /tag=MyTag /update-firewall /server=http://www.myserver.com/glpi/plugins/fusioninventory/ /rpc-trust-localhost /runnow"
UpdateArguments = "/execmode=none"
FusionSetupExe = "\\MyServer\MyShare\Fusioninventory\fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
'
' DO NOT EDIT BELOW
'
InstallCommand = FusionSetupExe & " " & FusionArguments
UpdateCommand = InstallCommand & " " & UpdateArguments
StopSvcCommand = "SC STOP ""FusionInventory-Agent"""
StartSvcCommand = "SC START ""FusionInventory-Agent"""
Set WshShell = Wscript.CreateObject("Wscript.shell")
' Get OS Type, 32 or 64 bit
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
' Extract installed version & uninstall command from registry
if (OsType = "x86") then
InstalledKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
UninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
else
InstalledKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
UninstallKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
end if
' Install FusionInventory-Agent if not yet installed
' If migrating from 2.1 to 2.2, first uninstall 2.1, then install 2.2
' Update FusionInventory if available version is newer than installed one
InstalledVersion = WshShell.RegRead(InstalledKey)
UninstallCommand = """" & WshShell.RegRead(UninstallKey) & """ /S"
' FusionInventory-Agent not yet installed, so install it
if InstalledVersion = "" then
Wscript.Echo "FusionInventory-Agent not installed, installing v. " & AvailableVersion
'Wscript.Echo "Running command: " & InstallCommand
WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True
' Upgrade from version 2.1 to version 2.2
' Must uninstall version 2.1 first, then install version 2.2
elseif InstalledVersion < "2.2" and AvailableVersion > "2.2" then
Wscript.Echo "Uninstalling FusionInventory-Agent v. " & InstalledVersion & " & installing v. " & AvailableVersion
'Wscript.Echo "Running commands:" & vbCrLf & " " & StopSvcCommand & vbCrLf & " " & UninstallCommand & vbCrLf & " " & InstallCommand
' Stop the FusioInventory-Agent service
WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
' Uninstal the agent
WshShell.Run "CMD.EXE /C """ & Uninstallcommand & """",0,True
' Wait 30 seconds
WScript.Sleep (30 * 1000)
' Install new version of the agent
WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True
' Update from version 2.2.x to version 2.2.y if y > x, then restart service
elseif InstalledVersion < AvailableVersion then
Wscript.Echo "Installed version: " & InstalledVersion & vbCrLf & "New version available: " & AvailableVersion
' Stop the FusioInventory-Agent servive
WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
'Wscript.Echo "Running command: " & UpdateCommand
WshShell.Run "CMD.EXE /C """ & UpdateCommand & """",0,True
' Start the FusioInventory-Agent servive
WshShell.Run "CMD.EXE /C """ & StartSvcCommand & """",0,True
else
Wscript.Echo "Current version " & InstalledVersion & " is up to date"
end if
Wscript.Echo "End of FusionInventory " & AvailableVersion & " deployment." & VbCrLf
GLPI 9.4.5 - Fusioninventory for GLPI 9.4+2.4 - Fusioninventory Agent 2.5.2
Je pense qu'il faudrait garder encore le pavé de désinstallation de OCS dans
le futur installer et mettre un choix 1 = desinstaller OCS , 0 = garder OCS
Merci
GLPI 0.90.5/ Plugins Fusion : 090+1.4 / Agent : 2.3.18 < Serveur Centos 64 Bits>
Voici la dernière version de mon script d'installation / mise à jour / mise à niveau depuis la version 2.1.
Je n'ai pas intégré de désinstallation d'OCS car je n'en ai pas l'usage, je veux garder le script relativement compact, et d'autres scripts le font très bien.
J'ai ajouté un paramètre optionnel "/S" pour rendre le script silencieux. Ainsi si je l'utilise directement il me dit ce qu'il fait, mais quand je l'utilise dans une GPO j'ajoute le paramètre "/S" car je me suis rendu compte que les utilisateurs sous Windows XP voient les messages apparaître, alors que tout va bien sous Windows 7
Goneri, pourras-tu le mettre dans la page dédiée à l'installation en masse, je n'ai pas les droits pour le faire.
Code: '
' FusionInventory-Deploy.vbs
'
' Use this script to automatically
' - install FusionInventory-Agent
' - upgrade from version 2.1 to 2.2
' - update version 2.2.x to 2.2.y
'
' You can run this script manually or use it as a startup script in a computer policy in an Active Directoy forest
'
' Just put the path to fusioninventory-agent_windows-i386_2.2.x.exe in the "FusionSetupExe" variable,
' and set the other variables in the USER SETTINGS section
'
' Versions :
' 2012-11-22 : initial
' 2012-11-26 : added upgrade from version 2.1 & more comments
' 2013-01-09 : updated the displayed messages
' 2013-02-18 : display messages only if IsVerbose is True (for silent use in GPO with /S parameter)
'
' Author : Marc Caissial <contact@zenitique.fr>
'
' My thanks to the authors of the "fusioninventory.vbs" script on the documentation page
' and to Tomas Abad <tabad@sescam.jccm.es> for his Resources kit for massive and unattended tasks
' that I found on the FusionInventory Forge, and that I used in my upgrade part
'
'
Option Explicit
On Error Resume Next
Dim AvailableVersion, InstalledVersion, FusionArguments, UpdateArguments, FusionSetupExe, WshShell, OSType, InstallCommand, UpdateCommand, StopSvcCommand, StartSvcCommand, UninstallCommand, InstalledKey, UninstallKey, IsVerbose
'
' USER SETTINGS
'
AvailableVersion = "2.2.7-3"
FusionArguments = "/S /tag=MyTag /update-firewall /server=http://www.mydomain.com/glpi/plugins/fusioninventory/ /rpc-trust-localhost /runnow"
UpdateArguments = "/execmode=none"
FusionSetupExe = "\\MyServer\MyShare\fusioninventory\fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
'
' DO NOT EDIT BELOW
'
IsVerbose = True
if wscript.Arguments.length = 1 then if wscript.Arguments(0) = "/s" OR wscript.Arguments(0) = "/S" then IsVerbose = False
InstallCommand = FusionSetupExe & " " & FusionArguments
UpdateCommand = InstallCommand & " " & UpdateArguments
StopSvcCommand = "SC STOP ""FusionInventory-Agent"""
StartSvcCommand = "SC START ""FusionInventory-Agent"""
Set WshShell = Wscript.CreateObject("Wscript.shell")
' Get OS Type, 32 or 64 bit
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
' Extract installed version & uninstall command from registry
if (OsType = "x86") then
InstalledKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
UninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
else
InstalledKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
UninstallKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
end if
' Install FusionInventory-Agent if not yet installed
' If migrating from 2.1 to 2.2, first uninstall 2.1, then install 2.2
' Update FusionInventory if available version is newer than installed one
InstalledVersion = WshShell.RegRead(InstalledKey)
UninstallCommand = """" & WshShell.RegRead(UninstallKey) & """ /S"
' FusionInventory-Agent not yet installed, so install it
if InstalledVersion = "" then
if IsVerbose then Wscript.Echo "FusionInventory-Agent not installed, installing v. " & AvailableVersion & "..."
'Wscript.Echo "Running command: " & InstallCommand
WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True
' Upgrade from version 2.1 to version 2.2
' Must uninstall version 2.1 first, then install version 2.2
elseif InstalledVersion < "2.2" and AvailableVersion > "2.2" then
if IsVerbose then Wscript.Echo "Uninstalling FusionInventory-Agent v. " & InstalledVersion & " & upgrading to v. " & AvailableVersion & "..."
'Wscript.Echo "Running commands:" & vbCrLf & " " & StopSvcCommand & vbCrLf & " " & UninstallCommand & vbCrLf & " " & InstallCommand
' Stop the FusioInventory-Agent service
WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
' Uninstal the agent
WshShell.Run "CMD.EXE /C """ & Uninstallcommand & """",0,True
' Wait 30 seconds
WScript.Sleep (30 * 1000)
' Install new version of the agent
WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True
' Update from version 2.2.x to version 2.2.y if y > x, then restart service
elseif InstalledVersion < AvailableVersion then
if IsVerbose then Wscript.Echo "Updating FusionInventory-Agent v." & InstalledVersion & " to new v." & AvailableVersion & "..."
' Stop the FusioInventory-Agent servive
WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
'Wscript.Echo "Running command: " & UpdateCommand
WshShell.Run "CMD.EXE /C """ & UpdateCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
' Start the FusioInventory-Agent servive
WshShell.Run "CMD.EXE /C """ & StartSvcCommand & """",0,True
' Nothing to do
else
if IsVerbose then Wscript.Echo "Current FusionInventory-Agent v." & InstalledVersion & " is up to date."
end if
'Done
if IsVerbose then Wscript.Echo "End of FusionInventory-Agent v." & AvailableVersion & " deployment." & VbCrLf
GLPI 9.4.5 - Fusioninventory for GLPI 9.4+2.4 - Fusioninventory Agent 2.5.2
Voici une nouvelle version du script VBS d'installation / déploiement par GPO ou manuellement depuis une clef USB ou un partage réseau :
- nouveau paramètre /H qui affiche les paramètres disponibles
- nouveau paramètre /D qui permet de supprimer l'item "FusionInventory Status" dans le menu démarrer, très pratique pour déploiement par GPO
Code: '
' FusionInventory-Deploy.vbs
'
' Use this script to automatically
' - install FusionInventory-Agent
' - upgrade from version 2.1 to 2.2
' - update version 2.2.x to 2.2.y
'
' You can run this script manually or use it as a startup script in a computer policy in an Active Directoy forest
'
' Just put the path to fusioninventory-agent_windows-i386_2.2.x.exe in the "FusionSetupExe" variable,
' and set the other variables in the USER SETTINGS section
'
' Versions :
' 2012-11-22 : initial
' 2012-11-26 : added upgrade from version 2.1 & more comments
' 2013-01-09 : updated the displayed messages
' 2013-02-18 : display messages only if IsVerbose is True (for silent use in GPO with /S parameter)
' 2013-04-25 : delete Start Menu item if /D parameter is used ; display usage with /? or /H parameter
'
' Author : Marc Caissial <contact@zenitique.fr>
'
' My thanks to the authors of the "fusioninventory.vbs" script on the documentation page
' and to Tomas Abad <tabad@sescam.jccm.es> for his Resources kit for massive and unattended tasks
' that I found on the FusionInventory Forge, and that I used in my upgrade part
'
'
Option Explicit
On Error Resume Next
Dim AvailableVersion, InstalledVersion, FusionArguments, UpdateArguments, FusionSetupExe, WshShell, wshFSO, OSType, InstallCommand, UpdateCommand, StopSvcCommand, StartSvcCommand, UninstallCommand, InstalledKey, UninstallKey, strArg,IsVerbose, DeleteStartMenuItem, StartMenuItemFile
'
' USER SETTINGS
'
AvailableVersion = "2.2.7-4"
FusionArguments = "/S /tag=MyTag /update-firewall /server=http://www.mydomain.com/glpi/plugins/fusioninventory/ /rpc-trust-localhost /runnow"
UpdateArguments = "/execmode=none"
FusionSetupExe = "\\MyServer\MyShare\fusioninventory\fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
'
' DO NOT EDIT BELOW
'
' Process command line arguments
IsVerbose = True
DeleteStartMenuItem = False
if wscript.Arguments.length >= 1 then
for each strArg in wscript.Arguments
if strArg = "/s" or strArg = "/S" then IsVerbose = False
if strArg = "/d" or strArg = "/D" then DeleteStartMenuItem = True
if strArg = "/h" or strArg = "/H" or strArg = "/?" then
wscript.Echo "Usage : " & wscript.ScriptName & " [/S] [/D] [/h]" & vbCrLf & " /S : Run in Silent Mode" & vbCrLf & " /D : Delete the ""FusionInventory Status"" item in the Start Menu" & vbCrLf & " /H : Display this help message and quit"
wscript.quit
end if
next
end if
InstallCommand = FusionSetupExe & " " & FusionArguments
UpdateCommand = InstallCommand & " " & UpdateArguments
StopSvcCommand = "SC STOP ""FusionInventory-Agent"""
StartSvcCommand = "SC START ""FusionInventory-Agent"""
set WshShell = Wscript.CreateObject("Wscript.shell")
StartMenuItemFile = wshShell.SpecialFolders("AllUsersPrograms") & "\FusionInventory Status.url"
' Get OS Type, 32 or 64 bit
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
' Extract installed version & uninstall command from registry
if (OsType = "x86") then
InstalledKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
UninstallKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
else
InstalledKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion"
UninstallKey = "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\UninstallString"
end if
' Install FusionInventory-Agent if not yet installed
' If migrating from 2.1 to 2.2, first uninstall 2.1, then install 2.2
' Update FusionInventory if available version is newer than installed one
InstalledVersion = WshShell.RegRead(InstalledKey)
UninstallCommand = """" & WshShell.RegRead(UninstallKey) & """ /S"
' FusionInventory-Agent not yet installed, so install it
if InstalledVersion = "" then
if IsVerbose then Wscript.Echo "FusionInventory-Agent not installed, installing v. " & AvailableVersion & "..."
'Wscript.Echo "Running command: " & InstallCommand
WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True
' Upgrade from version 2.1 to version 2.2
' Must uninstall version 2.1 first, then install version 2.2
elseif InstalledVersion < "2.2" and AvailableVersion > "2.2" then
if IsVerbose then Wscript.Echo "Uninstalling FusionInventory-Agent v. " & InstalledVersion & " & upgrading to v. " & AvailableVersion & "..."
'Wscript.Echo "Running commands:" & vbCrLf & " " & StopSvcCommand & vbCrLf & " " & UninstallCommand & vbCrLf & " " & InstallCommand
' Stop the FusioInventory-Agent service
WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
' Uninstal the agent
WshShell.Run "CMD.EXE /C """ & Uninstallcommand & """",0,True
' Wait 30 seconds
WScript.Sleep (30 * 1000)
' Install new version of the agent
WshShell.Run "CMD.EXE /C """ & InstallCommand & """",0,True
' Update from version 2.2.x to version 2.2.y if y > x, then restart service
elseif InstalledVersion < AvailableVersion then
if IsVerbose then Wscript.Echo "Updating FusionInventory-Agent v." & InstalledVersion & " to new v." & AvailableVersion & "..."
' Stop the FusioInventory-Agent servive
WshShell.Run "CMD.EXE /C """ & StopSvcCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
'Wscript.Echo "Running command: " & UpdateCommand
WshShell.Run "CMD.EXE /C """ & UpdateCommand & """",0,True
' Wait 5 seconds
WScript.Sleep (5 * 1000)
' Start the FusioInventory-Agent servive
WshShell.Run "CMD.EXE /C """ & StartSvcCommand & """",0,True
' Nothing to do
else
if IsVerbose then Wscript.Echo "Current FusionInventory-Agent v." & InstalledVersion & " is up to date."
end if
' Delete "FusionInventory Status" Start Menu item
if DeleteStartMenuItem then
set wshFSO = CreateObject("Scripting.FileSystemObject")
if wshFSO.FileExists (StartMenuItemFile) then
if IsVerbose then wscript.echo "File """ & StartMenuItemFile & """ deleted."
wshFSO.DeleteFile StartMenuItemFile, true
else
if IsVerbose then wscript.echo "File """ & StartMenuItemFile & """ doesn't exist."
end if
end if
'Done
if IsVerbose then Wscript.Echo "End of FusionInventory-Agent v." & AvailableVersion & " deployment." & VbCrLf
GLPI 9.4.5 - Fusioninventory for GLPI 9.4+2.4 - Fusioninventory Agent 2.5.2
Bonjour tout le monde,
Je suis utilisateur depuis un moment de glpi et je fais l'installation de l'agent moi même à la main sur les ordinateurs....pour le moment.
J'ai essayé de personnaliser le super code de ZenAdm mais...rien !
Est-ce que j'ai fait une erreur ??
AvailableVersion = "2.2.7-4"
FusionArguments = "/S /update-firewall /server=htt://xxxxxxxx/plugins/fusioninventory/ /rpc-trust-localhost /runnow"
UpdateArguments = "/execmode=none"
FusionSetupExe = "htt://prebuilt.fusioninventory.org/stable/windows-i386/fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
Merci d'avance
PS : j'ai supprimé volontairement le "p" de "http" car le forum ne voulait pas de 2 url dans mon post....
Bonjour,
Merci pour le compliment
Le problème vient de l'URL dans la variable "FusionSetupExe". L'installation ne peut se faire que depuis un disque local ou un chemin réseau, mais pas directement depuis une URL, car Windows ne sait pas le faire.
Cette variable "FusionSetupExe" contient la première partie de la ligne de commande qui est exécutée pour installer l'agent, la suite étant dans la variable "FusionArguments".
De mon côté, je télécharge l'agent, et soit :
- je le mets dans le même répertoire que le VBS, avec une variable "FusionSetupExe" qui vaut "fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
- je le mets sur un partage réseau, et dans le script la variable "FusionSetupExe" vaut alors "\\mon-serveur\mon-partage\fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
Hope it will help,
Marc
GLPI 9.4.5 - Fusioninventory for GLPI 9.4+2.4 - Fusioninventory Agent 2.5.2
Ok Ok I see, j'avais un petit doute sur cette fonctionnalité mais comme j'ai différents clients, le fait de pouvoir centraliser le .exe était super pour moi.
Bon je vais faire comme ta 1ère solution.
Merci Marc pour la réactivité et le travail
Dans le VBS fourni dans la doc de fusion, il y a la possibilité de mettre une URLpour que le VBS le télécharge sur le site web. C'est peut être à croiser entre les 2 scripts
J'ai testé effectivement cela fonctionne pour moi mais uniquement si le script est en local sur le PC impossible à lancer quand il est sur le réseau...
Une idée ?
Ah ben ça c'est le soucis du VBS, on ne peux pas le lancer quant il est sur un chemin réseau. Faut le copier avant sur le disque local (genre dossier temp)
Et après, comment rendre le script 100% silencieux et faire en sorte que si il est ajouté à une GPO il ne se réinstalle pas à chaque ouverture de session ?
Si tu le rajoute en GPO, met le en GPO ordinateur dans le NETLOGON et ça marchera sans soucis. le VBS est sensé détecté si l'agent est à installé t à jour (enfin pour celui qu'il y a dans la doc, j'ai jamais trop eu le temps de regarder celui de ZenAdm :/ )
On ne peut pas personnaliser le .exe avec ses options sinon ??
Tu peux mais ça veux dire que chaque pc va transférer systématiquement l'exe de plusieurs Mio à chaque démarrage de machine (genre goulot d'étranglement le matin)
L'idée est plus de mettre un .exe personnalisé à dispo en téléchargement sur notre site dans ce cas
Ben tu peux faire un script autoit et le compiler si tu veux absolument un exe
Voilà comment je procède avec mon script en GPO :
- je place dans le répertoire NETLOGON du domaine un dossier FusionInventory contenant mon script VBS et l'agent à installer (en ce moment, fusioninventory-agent_windows-i386_2.2.7-4)
- dans mon VBS, je positionne la variable FusionSetupExe = "\\mondomaine.local\NETLOGON\FusionInventory\fusioninventory-agent_windows-i386_" & AvailableVersion & ".exe"
- je crée une GPO Ordinateur, à exécuter au démarrage, contenant "\\mondomaine.local\NETLOGON\FusionInventory\FusionInventory-Deploy.vbs", avec les paramètres "/S /D" qui permettent une installation silencieuse et la suppression de l'entrée "FusionInventory Status" dans le menu démarrer
- je crée cette GPO avec "gpmc.msc", dans la rubrique "Configuration Ordinateur" -> "Stratégies" -> "Paramètres Windows" -> "Scripts (démarrage/arrêt)" -> "Démarrage"
Le script vérifie d'abord si l'agent est installé, puis si sa version est à jour, du coup la charge réseau est limitée au strict nécessaire et ça fonctionne très bien même sur un réseau étendu.
GLPI 9.4.5 - Fusioninventory for GLPI 9.4+2.4 - Fusioninventory Agent 2.5.2
|