Howtos:Deploy Office vbs on the agents with deploy or logon script
From OCS Inventory NG
| Note: The goal is to generate an executable which install plugins from a shared folder on network to the plugins directory on agent. |
Contents |
Prerequisites
- Install the latest version of AutoIT available here -> [1]
- The AutoIT package contents an integrate editor (Scite4AutoIT).
Compilation of the AutoIT script: InstallPlugins.au3
- Load the script into the editor. The content of the script is available at bottom of this page.
- Click on Tools menu and next Build or use CTRL+F7. The editor create an exe file -> InstallPlugins.exe
Test of the script
- Open a dos command windows
- Type in the following command : InstallPlugins.exe and valid with enter
- The installation go in very silent mode.
Script
Modify the script to define the path of shared folder on your network
---------------- AutoIt Version: 3.3.0.0 Auteur : Jean-Guy Dubois Copie de fichiers sur les postes locaux #ce ---------------------------------------------------------------------------- #include-once #include <File.au3> #include <Array.au3> Opt("TrayIconHide", 1) $logfile = @TempDir & "\OCS-Plugins.log" _FileWriteLog( $logfile, "************** Launch OCSPlugins.exe **************" ) ;~ If @OSArch = "IA64" Or @OSArch = "X64" Then ;~ $programfiles = @ProgramFilesDir & " (x86)" ;~ Else ;~ $programfiles = @ProgramFilesDir ;~ EndIf $programfiles=@ProgramFilesDir _FileWriteLog( $logfile, " Emplacement : "&$programfiles & "\OCS Inventory Agent\Plugins" ) If FileExists($programfiles & "\OCS Inventory Agent\Plugins") Then _FileWriteLog( $logfile, " Plugins existe bien" ) $attrib = FileGetAttrib($programfiles & "\OCS Inventory Agent\Plugins") _FileWriteLog( $logfile, " Attributs: "&$attrib ) If StringInStr($attrib, "D") Then _FileWriteLog( $logfile, " Plugins is a directory, good!" ) Else _FileWriteLog( $logfile, "ERR Plugins is not a directory" ) _FileWriteLog( $logfile, " Delete "& $programfiles & "\OCS Inventory Agent\Plugins" ) $deleteold = FileDelete($programfiles & "\OCS Inventory Agent\Plugins") Sleep(50) If not $deleteold Then _FileWriteLog( $logfile, "ERR Impossible to delete, program stop.") EndIf _FileWriteLog( $logfile, " Delete OK, result : "&$deleteold ) _FileWriteLog( $logfile, " Creation of directory, result : "&DirCreate($programfiles & "\OCS Inventory Agent\Plugins") ) EndIf Else _FileWriteLog( $logfile, " Plugins not found.") _FileWriteLog( $logfile, " Creation of directory, result : "&DirCreate($programfiles & "\OCS Inventory Agent\Plugins") ) EndIf ; DEFINE HERE YOUR PLUGINS DIRECTORY $listplugins = _FileListToArray( "\\SERVER\AppDeploy$\OCS-Plugins\") _ArrayDelete( $listplugins, 0 ) For $file In $listplugins $copy = FileCopy("\\SERVER\AppDeploy$\OCS-Plugins\"&$file, $programfiles & "\OCS Inventory Agent\Plugins\", 1) If $copy Then _FileWriteLog( $logfile, " Fichier "&$file&" Okey.") Else _FileWriteLog( $logfile, "ERR Fichier "&$file&", impossible !") EndIf Next