.bat script not running through scheduler

February 27, 2018 at 04:48:12
Specs: Windows 7
below .bat script not running through windows scheduler but working fine when entered directly with command console:

query user | findstr -vi "zSvcMIReporting USERNAME" > c:\Logged_User.txt

for /f "tokens=2" %i in (c:\Logged_User.txt) Do echo logoff %i >> c:\LogOff_User.txt

the first part/line is executing fine but I could not see the output of 2nd part when running it through .bat script through windows scheduler

Can anyone please help? Thanks in Advance

See More: .bat script not running through scheduler

Report •

February 27, 2018 at 05:35:34
If it's a batch file then you need to use double percent characters in the FOR loop. Single ones only work in the command prompt. So %%i instead of %i.

Don't worry if plan A fails, there are 25 more letters in the alphabet ;)

Report •

April 23, 2018 at 05:59:36
query user | findstr -vi "USERNAME" > c:\Logged_User2.txt
for /f "tokens=2" %%i in (c:\Logged_User2.txt) Do logoff %%i
for /f "tokens=3" %%i in (c:\Logged_User2.txt) Do logoff %%i

Above batch script when executed the command screen keeps on scrolling.
The purpose of the above batch script is to log off all the users logged in terminal

Report •
Related Solutions

Ask Question