enter image description hereenter image description hereIm fairly new to serious batch files. But i have a problem I'm sure can be solved with coding. i am in charge of keeping 100+ units product keyed, And we have to change them out when they go bad , but sometimes they don't get re-keyed so i'm trying to find a way to keep track of non activated windows units.
Before you ask no we don't have a volume license server, or anything related to that unfortunately. my boss is old school.
So i have a code that has:
@echo off
for /f %%i in (computers.txt) do shutdown -r -t 0 -m %%i// and that works fine and restarts all pcs i have in the .txt file in ip address form. then i run around trying to catch all the activation windows before they dissapear. but im trying to get it to check windows activation and output that to a text file with all the units that are NOT activated.
@echo off
for /f %%i in (computers.txt) do cscript /nologo c:\windows\system32\slmgr.vbs /xpr > ActivatedStatus.txt | findstr /i /c:" will expire "> NUL 2>&1
if [%errorlevel%]==[0] (echo Not permanently activated.) else (echo Permanently activated)
pause
exit /b
It works fine and checks the local pc im on but i just cant get it to push the command to a given set of ip addresses. any help would be greatly appreciated. been borrowing snipets of code from here to make this. figured it was time for help.
If your target OS is Windows 7
or newer, perhaps something along these lines may help you out:
@Echo Off
Set "XSL=csv"
For /F "EOL=MDelims=" %%A In ('"WMIc OS Get MUILanguages,Version"'
) Do For /F Tokens^=2^,4-5Delims^=.^"^ %%B In ("%%A"
) Do If %%C Equ 6 If %%D Equ 1 Set "XSL=%__APPDIR__%WBEM\%%B\%XSL%
WMIC /Output:Results.log /Node:@Computers.txt Path SoftwareLicensingProduct^
Where "PartialProductKey Is Not Null And Name Like 'Windows(R)%%' And Not LicenseStatus='1'"^
Get LicenseStatus,Name,ProductKeyID /Format:"%XSL%"
The idea is that it will check each of the Computers listed one per line in file named computers.txt
in the current working directory. If the Windows(R)
product is not showing as licensed, (i.e. 1
), it should output some pertinent information to a file named Results.log
also in your current working directory.
The License Status output would translate to one of the following:
0
: Unlicensed
1
: Licensed
2
: OOB Grace
3
: OOT Grace
4
: Non-Genuine Grace
5
: Notification
6
: Extended Grace
Note: You may not need lines 3
-5
of the script above if you're not checking from a Windows 7
machine, I added those because of a known issue with the location of the csv.xsl
file on versions of that OS.