Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2444 connectés 

  FORUM HardWare.fr
  Systèmes & Réseaux Pro
  Poste de travail

  Script Fusion qui ne marche pas

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Script Fusion qui ne marche pas

n°147570
Micko77666
Posté le 26-06-2017 à 16:42:56  profilanswer
 


Salut tout le monde,
 
 
 
Je rencontre un soucis avec le déploiement d'un script pour installer FusionInventory, ma GPO s'applique bien et mon script aussi (j'ai mis une ligne qui créé un répertoire pour être sur que le script est bien exécute).
Par contre rien ne se passe, si je mets la création du répertoire à la fin j'ai rien, donc il y a un moment où le script doit bloquer, mais je ne vois vraiment pas où. Surtout que si je le lance à la main, l'installation fonctionne très bien.
 
 
Voici le script (j'ai enlevé les commentaires pour faire plus petit) :
 
 
 

Code :
  1. Option Explicit
  2. Dim Force, Verbose, Fso
  3. Dim Setup, SetupArchitecture, SetupLocation, SetupOptions, SetupVersion
  4. SetupVersion = "2.3.20"
  5. SetupLocation = "\\serveur\fusioninventory"
  6. SetupArchitecture = "Auto"
  7. SetupOptions = "/acceptlicense /runnow /execmode=service /add-firewall-exception /no-ssl-check /server='https://glpi.*******/plugins/fusioninventory/' /S"
  8. Setup = "fusioninventory-agent_windows-x64_2.3.20.exe"
  9. Force = "Yes"
  10. 'Verbose = "Yes"
  11. Function AdvanceTime(nMinutes)
  12.    Dim nMinimalMinutes, dtmTimeFuture
  13.    ' As protection
  14.    nMinimalMinutes = 5
  15.    If nMinutes < nMinimalMinutes Then
  16.       nMinutes = nMinimalMinutes
  17.    End If
  18.    ' Add nMinutes to the current time
  19.    dtmTimeFuture = DateAdd ("n", nMinutes, Time)
  20.    ' Format the result value
  21.    '    The command AT accepts 'HH:MM' values only
  22.    AdvanceTime = Hour(dtmTimeFuture) & ":" & Minute(dtmTimeFuture)
  23. End Function
  24. Function baseName (strng)
  25.    Dim regEx, ret
  26.    Set regEx = New RegExp
  27.    regEx.Global = true
  28.    regEx.IgnoreCase = True
  29.    regEx.Pattern = ".*[/\\]([^/\\]+)$"
  30.    baseName = regEx.Replace(strng,"$1" )
  31. End Function
  32. Function GetSystemArchitecture()
  33.    Dim strSystemArchitecture
  34.    Err.Clear
  35.    ' Get operative system architecture
  36.    On Error Resume Next
  37.    strSystemArchitecture = CreateObject("WScript.Shell" ).ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%" )
  38.    If Err.Number = 0 Then
  39.       ' Check the operative system architecture
  40.       Select Case strSystemArchitecture
  41.          Case "x86"
  42.             ' The system architecture is 32-bit
  43.             GetSystemArchitecture = "x86"
  44.          Case "AMD64"
  45.             ' The system architecture is 64-bit
  46.             GetSystemArchitecture = "x64"
  47.          Case Else
  48.             ' The system architecture is not supported
  49.             GetSystemArchitecture = "NotSupported"
  50.       End Select
  51.    Else
  52.       ' It has been not possible to get the system architecture
  53.       GetSystemArchitecture = "Unknown"
  54.    End If
  55. End Function
  56. Function isHttp(strng)
  57.    Dim regEx, matches
  58.    Set regEx = New RegExp
  59.    regEx.Global = true
  60.    regEx.IgnoreCase = True
  61.    regEx.Pattern = "^(http(s?)).*"
  62.    If regEx.Execute(strng).count > 0 Then
  63.       isHttp = True
  64.    Else
  65.       isHttp = False
  66.    End If
  67.    Exit Function
  68. End Function
  69. Function IsInstallationNeeded(strSetupVersion, strSetupArchitecture, strSystemArchitecture)
  70.    Dim strCurrentSetupVersion
  71.    ' Compare the current version, whether it exists, with strSetupVersion
  72.    If strSystemArchitecture = "x86" Then
  73.       ' The system architecture is 32-bit
  74.       ' Check if the subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' exists
  75.       '    This subkey is now deprecated
  76.       On error resume next
  77.       strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion" )
  78.       If Err.Number = 0 Then
  79.       ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' exists
  80.          If strCurrentSetupVersion <> strSetupVersion Then
  81.             ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
  82.             IsInstallationNeeded = True
  83.          End If
  84.          Exit Function
  85.       Else
  86.          ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' doesn't exist
  87.          Err.Clear
  88.          ' Check if the subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
  89.          On error resume next
  90.          strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent\DisplayVersion" )
  91.          If Err.Number = 0 Then
  92.          ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
  93.             If strCurrentSetupVersion <> strSetupVersion Then
  94.                ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
  95.                IsInstallationNeeded = True
  96.             End If
  97.             Exit Function
  98.          Else
  99.             ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' doesn't exist
  100.             Err.Clear
  101.             ShowMessage("Installation needed: " & strSetupVersion)
  102.             IsInstallationNeeded = True
  103.          End If
  104.       End If
  105.    Else
  106.       ' The system architecture is 64-bit
  107.       ' Check if the subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' exists
  108.       '    This subkey is now deprecated
  109.       On error resume next
  110.       strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent\DisplayVersion" )
  111.       If Err.Number = 0 Then
  112.       ' The subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' exists
  113.          If strCurrentSetupVersion <> strSetupVersion Then
  114.             ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
  115.             IsInstallationNeeded = True
  116.          End If
  117.          Exit Function
  118.       Else
  119.          ' The subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory Agent' doesn't exist
  120.          Err.Clear
  121.          ' Check if the subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
  122.          On error resume next
  123.          strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent\DisplayVersion" )
  124.          If Err.Number = 0 Then
  125.          ' The subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
  126.             If strCurrentSetupVersion <> strSetupVersion Then
  127.                ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
  128.                IsInstallationNeeded = True
  129.             End If
  130.             Exit Function
  131.          Else
  132.             ' The subkey 'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' doesn't exist
  133.             Err.Clear
  134.             ' Check if the subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
  135.             On error resume next
  136.             strCurrentSetupVersion = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent\DisplayVersion" )
  137.             If Err.Number = 0 Then
  138.             ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' exists
  139.                If strCurrentSetupVersion <> strSetupVersion Then
  140.                   ShowMessage("Installation needed: " & strCurrentSetupVersion & " -> " & strSetupVersion)
  141.                   IsInstallationNeeded = True
  142.                End If
  143.                Exit Function
  144.             Else
  145.                ' The subkey 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\FusionInventory-Agent' doesn't exist
  146.                Err.Clear
  147.                ShowMessage("Installation needed: " & strSetupVersion)
  148.                IsInstallationNeeded = True
  149.             End If
  150.          End If
  151.       End If
  152.    End If
  153. End Function
  154. Function IsSelectedForce()
  155.    If LCase(Force) <> "no" Then
  156.       ShowMessage("Installation forced: " & SetupVersion)
  157.       IsSelectedForce = True
  158.    Else
  159.       IsSelectedForce = False
  160.    End If
  161. End Function
  162. ' http://www.ericphelps.com/scriptin [...] index.html
  163. Function SaveWebBinary(strSetupLocation, strSetup)
  164.    Const adTypeBinary = 1
  165.    Const adSaveCreateOverWrite = 2
  166.    Const ForWriting = 2
  167.    Dim web, varByteArray, strData, strBuffer, lngCounter, ado, strUrl
  168.    strUrl = strSetupLocation & "/" & strSetup
  169.    'On Error Resume Next
  170.    'Download the file with any available object
  171.    Err.Clear
  172.    Set web = Nothing
  173.    Set web = CreateObject("WinHttp.WinHttpRequest.5.1" )
  174.    If web Is Nothing Then Set web = CreateObject("WinHttp.WinHttpRequest" )
  175.    If web Is Nothing Then Set web = CreateObject("MSXML2.ServerXMLHTTP" )
  176.    If web Is Nothing Then Set web = CreateObject("Microsoft.XMLHTTP" )
  177.    web.Open "GET", strURL, False
  178.    web.Send
  179.    If Err.Number <> 0 Then
  180.       SaveWebBinary = False
  181.       Set web = Nothing
  182.       Exit Function
  183.    End If
  184.    If web.Status <> "200" Then
  185.       SaveWebBinary = False
  186.       Set web = Nothing
  187.       Exit Function
  188.    End If
  189.    varByteArray = web.ResponseBody
  190.    Set web = Nothing
  191.    'Now save the file with any available method
  192.    On Error Resume Next
  193.    Set ado = Nothing
  194.    Set ado = CreateObject("ADODB.Stream" )
  195.    If ado Is Nothing Then
  196.       Set fs = CreateObject("Scripting.FileSystemObject" )
  197.       Set ts = fs.OpenTextFile(baseName(strUrl), ForWriting, True)
  198.       strData = ""
  199.       strBuffer = ""
  200.       For lngCounter = 0 to UBound(varByteArray)
  201.          ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1)))
  202.       Next
  203.       ts.Close
  204.    Else
  205.       ado.Type = adTypeBinary
  206.       ado.Open
  207.       ado.Write varByteArray
  208.       ado.SaveToFile CreateObject("WScript.Shell" ).ExpandEnvironmentStrings("%TEMP%" ) & "\" & strSetup, adSaveCreateOverWrite
  209.       ado.Close
  210.    End If
  211.    SaveWebBinary = True
  212. End Function
  213. Function ShowMessage(strMessage)
  214.    If LCase(Verbose) <> "no" Then
  215.       WScript.Echo strMessage
  216.    End If
  217. End Function
  218. '
  219. '
  220. ' MAIN
  221. '
  222. '
  223. Dim nMinutesToAdvance, strCmd, strSystemArchitecture, strTempDir, WshShell
  224. Set WshShell = WScript.CreateObject("WScript.shell" )
  225. nMinutesToAdvance = 5
  226. ' Get system architecture
  227. strSystemArchitecture = GetSystemArchitecture()
  228. If (strSystemArchitecture <> "x86" ) And (strSystemArchitecture <> "x64" ) Then
  229.    ShowMessage("The system architecture is unknown or not supported." )
  230.    ShowMessage("Deployment aborted!" )
  231.    WScript.Quit 1
  232. Else
  233.    ShowMessage("System architecture detected: " & strSystemArchitecture)
  234. End If
  235. ' Check and auto detect SetupArchitecture
  236. Select Case LCase(SetupArchitecture)
  237.    Case "x86"
  238.       ' The setup architecture is 32-bit
  239.       SetupArchitecture = "x86"
  240.       Setup = Replace(Setup, "x86", SetupArchitecture, 1, 1, vbTextCompare)
  241.       ShowMessage("Setup architecture: " & SetupArchitecture)
  242.    Case "x64"
  243.       ' The setup architecture is 64-bit
  244.       SetupArchitecture = "x64"
  245.       Setup = Replace(Setup, "x64", SetupArchitecture, 1, 1, vbTextCompare)
  246.       ShowMessage("Setup architecture: " & SetupArchitecture)
  247.    Case "auto"
  248.       ' Auto detection of SetupArchitecture
  249.       SetupArchitecture = strSystemArchitecture
  250.       Setup = Replace(Setup, "Auto", SetupArchitecture, 1, 1, vbTextCompare)
  251.       ShowMessage("Setup architecture detected: " & SetupArchitecture)
  252.    Case Else
  253.       ' The setup architecture is not supported
  254.       ShowMessage("The setup architecture '" & SetupArchitecture & "' is not supported." )
  255.       WScript.Quit 2
  256. End Select
  257. ' Check the relation between strSystemArchitecture and SetupArchitecture
  258. If (strSystemArchitecture = "x86" ) And (SetupArchitecture = "x64" ) Then
  259.    ' It isn't possible to execute a 64-bit setup on a 32-bit operative system
  260.    ShowMessage("It isn't possible to execute a 64-bit setup on a 32-bit operative system." )
  261.    ShowMessage("Deployment aborted!" )
  262.    WScript.Quit 3
  263. End If
  264. If IsSelectedForce() Or IsInstallationNeeded(SetupVersion, SetupArchitecture, strSystemArchitecture) Then
  265.    If isHttp(SetupLocation) Then
  266.       ShowMessage("Downloading: " & SetupLocation & "/" & Setup)
  267.       If SaveWebBinary(SetupLocation, Setup) Then
  268.          strCmd = WshShell.ExpandEnvironmentStrings("%ComSpec%" )
  269.          strTempDir = WshShell.ExpandEnvironmentStrings("%TEMP%" )
  270.          ShowMessage("Running: """ & strTempDir & "\" & Setup & """ " & SetupOptions)
  271.          WshShell.Run """" & strTempDir & "\" & Setup & """ " & SetupOptions, 0, True
  272.          ShowMessage("Scheduling: DEL /Q /F """ & strTempDir & "\" & Setup & """" )
  273.          WshShell.Run "AT.EXE " & AdvanceTime(nMinutesToAdvance) & " " & strCmd & " /C ""DEL /Q /F """"" & strTempDir & "\" & Setup & """""", 0, True
  274.          ShowMessage("Deployment done!" )
  275.       Else
  276.          ShowMessage("Error downloading '" & SetupLocation & "\" & Setup & "'!" )
  277.       End If
  278.    Else
  279.       ShowMessage("Running: """ & SetupLocation & "\" & Setup & """ " & SetupOptions)
  280.       WshShell.Run "CMD.EXE /C """ & SetupLocation & "\" & Setup & """ " & SetupOptions, 0, True
  281.       ShowMessage("Deployment done!" )
  282.    End If
  283. Else
  284.    ShowMessage("It isn't needed the installation of '" & Setup & "'." )
  285. End If
  286. Set fso = WScript.CreateObject("Scripting.FileSystemObject" )
  287. fso.CreateFolder("\\test\Deploiement\installOK\testLigne370" )


 
 
Avez-vous une idée ? car je vois vraiment pas ce qui peut bloquer dans le script :(
 

mood
Publicité
Posté le 26-06-2017 à 16:42:56  profilanswer
 

n°147571
nebulios
Posté le 26-06-2017 à 17:23:11  profilanswer
 

Tu vérifies l'architecture alors que tu as une fonction pour, la fonction AT n'est plus supportée, utilise des noms d'hôte plutôt que les noms NetBIOS etc...
 
Plus globalement évite les scripts de 300 lignes pour déployer un pauvre MSI...tu n'as pas moyen de faire ça en PowerShell ?

n°147572
Micko77666
Posté le 26-06-2017 à 17:31:12  profilanswer
 


Il s'agit du script de base que FusionInventoy distribu sur leur site pour le déploiement de l'agent.
 
Concernant ce script du coup il faudrait modifier quoi ?

n°147583
i'm philou
Posté le 27-06-2017 à 12:11:00  profilanswer
 

C'est bien une GPO machine que tu as fait ?

n°147584
nebulios
Posté le 27-06-2017 à 12:16:35  profilanswer
 

Oublie cette usine à gaz et créé un script PowerShell de 30 lignes au lieu de 300 qui fera la même chose.
 
Tu as ce genre de comportement en VBS soit parce que le moteur de script n'est pas approprié (wscript/cscript), soit parce que l'UAC te bloque -> vérifie que tu as une GPO ordinateur.

n°147597
Micko77666
Posté le 27-06-2017 à 13:40:01  profilanswer
 


Pour la GPO est ordinateur ça c'est sur, quand je le lance à la main effectivement j'ai l'UAC qui demande une validation.
 
Les scripts PowerShell ne pose pas de soucis sur les postes clients ? (jamais utilisé de script powershell encore pour le déploiement d'application).

n°147622
nebulios
Posté le 28-06-2017 à 02:56:05  profilanswer
 

Non si tu respectes les prérequis. Dans les GPO tu as une option pour spécifier que ton script est en Powershell.

n°147623
Micko77666
Posté le 28-06-2017 à 06:52:43  profilanswer
 


D'accord merci de l'info je vais regarder ça, car effectivement ça fait très usine à gaz. Par contre ce qui m'étonne c'est que ce script est très utilisé car fourni de base avec Fusion Inventory, c'est la que je vois pas pourquoi ça marche pas.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Systèmes & Réseaux Pro
  Poste de travail

  Script Fusion qui ne marche pas

 

Sujets relatifs
Script (PowerShell ?) et port knockingCopie répertoire via un script powershell sur plusieurs postes
Changement de tag fusion inventory a distanceDésinstallation du pack office en réseau avec un script
Script apparence et performance Windows 10GPO (Fusion avec paramètres présents)
Agent Fusion inventoryFusion de structures et AD - approche -
Portail web pour lancement script shell sur serveur applicatif[Script de Logon] Les lecteurs réseau ne mappent plus !
Plus de sujets relatifs à : Script Fusion qui ne marche pas


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR