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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -