Batch Script to check Windows 7 Activation -
i trying batch script check activation status of workstations of lan, far have following code saves .txt status of activation.
@echo off cscript /nologo c:\windows\system32\slmgr.vbs /xpr > activatedstatus.txt | findstr /i /c:" expire "> nul 2>&1 if [%errorlevel%]==[0] (echo not permanently activated.) else (echo permanently activated) exit /b
an output activatedstatus.txt looks this:
windows(r) 7, professional edition: machine permanently activated.
what want create .txt if workstation not activated can't work if statements.
by both attempting both redirect , pipe on same command line, you're redirecting, nothing being feed findstr
. so, you'll either need pipe data along:
cscript /nologo c:\windows\system32\slmgr.vbs /xpr | findstr /i /c:" expire "> nul 2>&1
or, if want create text file, need create first, pipe it's data findstr
:
cscript /nologo c:\windows\system32\slmgr.vbs /xpr > activatedstatus.txt type activatedstatus.txt | findstr /i /c:" expire "> nul 2>&1
Comments
Post a Comment