Need help with batch file.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
silent
Posts: 44
Joined: 28 Oct 2011 14:40

Need help with batch file.

#1 Post by silent » 28 Oct 2011 14:45

Hi,im new on the forum.From some time i want to make a batch file that will have a limit,that if i will run it for second time it wont allow me to continue example : limit of opens is set to 5,if trying to open bat file again it will show text like "echo Limit reached,write password to reset trial" Any ideas how to make something like this ? if it is even possible ?

aGerman
Expert
Posts: 4705
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Need help with batch file.

#2 Post by aGerman » 28 Oct 2011 15:06

A password request in a batch file? That doesn't make any sense.

However you could count all windows which have the same window title.

Code: Select all

@echo off &setlocal
title limit test
set /a n=0
for /f %%i in ('tasklist /fi "imagename eq cmd.exe" /fi "windowtitle eq limit test" /nh^|find "cmd.exe"') do set /a n+=1
echo %n%
pause

Regards
aGerman

Post Reply