Print Result in Variable Obtained by for
Posted: 28 Aug 2018 14:32
how do I manage to demand the result obtained in the for?
@echo off
setlocal
setlocal EnableExtensions
setlocal EnableDelayedExpansion
set "usr1_name=user1"
for /F "skip=1 delims= " %%a in ('wmic useraccount where name^="%usr1_name%" get passwordexpires') do (
set usr1_passwdexpiretmp=%%a
)
for /F "skip=1 delims= " %%b in ('wmic useraccount where name^="%usr1_name%" get passwordchangeable') do (
set usr1_passwordchangeabletmp=%%b
)
echo %usr1_passwdexpiretmp%
echo %usr1_passwordchangeabletmp%
pause
Result:
ECHO It's deactivated
ECHO It's deactivated
@echo off
setlocal
setlocal EnableExtensions
setlocal EnableDelayedExpansion
set "usr1_name=user1"
for /F "skip=1 delims= " %%a in ('wmic useraccount where name^="%usr1_name%" get passwordexpires') do (
set usr1_passwdexpiretmp=%%a
)
for /F "skip=1 delims= " %%b in ('wmic useraccount where name^="%usr1_name%" get passwordchangeable') do (
set usr1_passwordchangeabletmp=%%b
)
echo %usr1_passwdexpiretmp%
echo %usr1_passwordchangeabletmp%
pause
Result:
ECHO It's deactivated
ECHO It's deactivated