@echo off setlocal enabledelayedexpansion rem ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' rem rem Copyright (C) 2013, Microsoft Corporation. rem All rights reserved. rem rem File Name: rem silcollector.cmd rem rem Abstract: rem This script supports two modes: rem 1. To configure SIL from the boot task. rem 2. To invoke collection from the collector task. rem rem ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' set configurationlog="%temp%\silconfig.log" if "%~1"=="configure" goto configure if "%~1"=="publish" goto publish :usage echo silcollector.cmd configure echo silcollector.cmd publish [configuration file] goto :eof :configure for /f "tokens=3 delims= " %%g in ('%systemroot%\system32\reg.exe query hklm\software\microsoft\windows\softwareinventorylogging /v collectionstate /reg:64') do ( set /a loggingstate=%%g ) if "%loggingstate%"=="0" ( echo "%date% @ %time% --> Not configuring Software Inventory Logging as it is not enabled." > %configurationlog% goto :eof ) for /f "tokens=3 delims= " %%g in ('%systemroot%\system32\reg.exe query hklm\software\microsoft\windows\softwareinventorylogging /v collectiontime /reg:64') do ( set loggingtime=%%g ) for /f "tokens=1-8 delims=-T:+" %%g in ("%loggingtime%") do ( set year=%%g set month=%%h set day=%%i set hour=%%j set minute=%%k set second=%%l set /a tzoffset=0 set /a tzoffset=%%m*60 + %%n ) echo "%date% @ %time% --> Enabling Software Inventory Logging to publish data at %year%/%month%/%day% %hour%:%minute%:%second%+%tzoffset%" > %configurationlog% %systemroot%\system32\wbem\wmic.exe /namespace:\\root\inventorylogging path msftsil_managementtasks call setloggingstate %loggingstate% >NUL 2>&1 if %ERRORLEVEL% neq 0 ( echo "%date% @ %time% --> Failed to enable Software Inventory Logging with error code %ERRORLEVEL%." >> %configurationlog% ) goto :eof :publish set config=%~2 if "%config%"=="" set config=silstream.mof %systemroot%\system32\wbem\wmic.exe /namespace:\\root\inventorylogging path msft_mistreamtasks call push true,%config% >NUL 2>&1 goto :eof