Most of the time a specific scripting language is chosen to provide an automated solution for something.
In this case a customer was already using batch scripting. I was adding simple VBscripts to query the WMI Namespaces. Well, how to use these different scripts in hybrid and pass values back to the original batch startup script?
The VBS being used in this example is checking WMI for the Write Filter State (used in the Windows Embedded OS).
Microsoft is using the commands available to check and manage the filter and splitting the huge output to find the current state of the writefilter here. In my opinion it is better to use the information available in WMI:
1 2 3 4 5 6 7 8 |
strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\Microsoft\WriteFilters") Set colItems = objWMIService.ExecQuery("SELECT StateName FROM EwfVolumeConfiguration WHERE StateName = 'Enabled'") For Each objItem in colItems If objItem.StateName = "Enabled" Then WScript.Echo objItem.StateName End If Next |
The cscript //nologo is the most important part of the command you use to start the .VBS!
When we compare the output without the nologo switch we see these differences:
Now to call the and get it’s result and put it in a variable
1 2 |
FOR /F %%E in ('cscript //nologo \\domain\NETLOGON\EWFquery.vbs') DO SET EWF=%%E IF "%EWF%"=="Enabled" GOTO disableewf |
BTW, Very usefull when creating WMI code is the WMI Code Generator created by Rob van der Woude.