Search found 104 matches

by PAB
03 Aug 2020 13:17
Forum: DOS Batch Forum
Topic: Console output to text file missing entries.
Replies: 1
Views: 5

Console output to text file missing entries.

Good evening everyone. I have this cmd . . . for /f "tokens=*" %%i in ('wevtutil.exe el') do echo "%%i" & wevtutil.exe cl "%%i" & wevtutil.exe cl System When I run it, it outputs the list and any ERRORS to the console, great so far! I put that in a separate .bat file and called it from another .bat ...
by PAB
03 Aug 2020 12:56
Forum: DOS Batch Forum
Topic: Only accept a numeric number.
Replies: 11
Views: 171

Re: Only accept a numeric number.

First of all, thank you to everyone who has contributed to this question, it is very much appreciated! You should change the order and use delayed expansion when testing for other characters, else someone could inject commands: for /f "delims=0123456789" %%a in ("!OS_Index!") do goto :Menu if "%OS_I...
by PAB
31 Jul 2020 01:55
Forum: DOS Batch Forum
Topic: Only accept a numeric number.
Replies: 11
Views: 171

Re: Only accept a numeric number.

Good morning. Thanks for the help EVERYONE , it is appreciated. Here is the finished code. It will only accept numbers 1 to 12 which is what I want. It will hold the value of %OS_Index% so I can use it in several sections of the code further down. @echo off setlocal enabledelayedexpansion :Menu set ...
by PAB
30 Jul 2020 16:59
Forum: DOS Batch Forum
Topic: Only accept a numeric number.
Replies: 11
Views: 171

Re: Only accept a numeric number.

Thanks Squashman , that works great. I will keep trying to sort out number [2] above if I can! Yes, I have always had a problem with quotes knowing when and when not to use them, but I am gradually getting to understand it a bit more. They say you can't teach an old dog new tricks, but I do try, rea...
by PAB
30 Jul 2020 16:31
Forum: DOS Batch Forum
Topic: Only accept a numeric number.
Replies: 11
Views: 171

Re: Only accept a numeric number.

Thank you BOTH VERY MUCH for the replies, it is appreciated. I have two problems . . . [1] I can' get the greater than 12 to work properly. [2] I can't seem to add an OS_Index variable that will hold the value of %userinput% . The reason for this is that I use %userinput% further down the code so se...
by PAB
30 Jul 2020 09:54
Forum: DOS Batch Forum
Topic: Only accept a numeric number.
Replies: 11
Views: 171

Only accept a numeric number.

Good afternoon! I want to be able to use the user input value as a variable further down some code rather than having to hard code the number. The code below works, but it relies on the fact that there actually is a number input and it is a number that is valid. Here is the test code I have got . . ...
by PAB
30 Jul 2020 09:38
Forum: DOS Batch Forum
Topic: Quotation Marks.
Replies: 2
Views: 76

Re: Quotation Marks.

Wow, THANK YOU jfl for the detailed reply and insight.
I will have to ponder on that for a while and investigate further to get it clear in my mind.
by PAB
29 Jul 2020 11:13
Forum: DOS Batch Forum
Topic: Quotation Marks.
Replies: 2
Views: 76

Quotation Marks.

Good afternoon, Being an old git, I have always had problems with knowing whether quotation marks should be used or not. When browsing the Internet, there are many bits of code out there, some of which use quotation marks and some that don't to achieve thae SAME thing. To try and clarify things in m...
by PAB
24 Jul 2020 06:14
Forum: DOS Batch Forum
Topic: Extract data from a text file.
Replies: 0
Views: 134

Extract data from a text file.

Good afternoon, I have managed to write the following which WORKS if there is ONLY one set of entries [ as per the %Filter% ] in the thousands of lines that appear in the CBS log. If there are more than one entry for each it outputs all of them! Is there any way that I can just get the LAST set of e...
by PAB
22 Jul 2020 07:22
Forum: DOS Batch Forum
Topic: Problem with ELSE.
Replies: 2
Views: 188

Re: Problem with ELSE.

I just couldn't seem to get it to do the WHOLE thing using If..Else...Else so I have come up with this . . . set "Drive=" echo Which drive would you like to check for ERRORS? set /p "Drive=>Please enter the drive letter and press <Enter>: " if /i not exist %Drive%:\ goto :ERROR if /i "%Drive%"=="C" ...
by PAB
21 Jul 2020 17:30
Forum: DOS Batch Forum
Topic: Problem with ELSE.
Replies: 2
Views: 188

Problem with ELSE.

Good evening, I have this code . . . set "Drive=" echo Which drive would you like to check for ERRORS? set /p "Drive=>Please enter the drive letter and press <Enter>: " if not exist %volume% %Drive%:\ ( echo ERROR: The drive does NOT exist^^! echo ^>Press ANY key to return to the Options . . . & pau...
by PAB
18 Jul 2020 02:13
Forum: DOS Batch Forum
Topic: [SOLVED] cmd prompt will not run maximized after CALL script ends.
Replies: 2
Views: 199

Re: cmd prompt will not run maximized after CALL script ends.

the primary program resumes from the point the call is made - If the :menu label occurs prior to the call, it will not be parsed. Thanks for the reply, it is appreciated. Seeing as the default cmd prompt size is 80 columns x 300 lines, I got round it like this which is enough lines for my needs . ....
by PAB
17 Jul 2020 14:41
Forum: DOS Batch Forum
Topic: [SOLVED] cmd prompt will not run maximized after CALL script ends.
Replies: 2
Views: 199

[SOLVED] cmd prompt will not run maximized after CALL script ends.

Good evening, I have a script where I want to CALL another batch script. call "%~dp0bin\Test_CALL_File.bat" The problem I am having is that the CALL ed batch script runs in a modified cmd prompt size using . . . mode con: cols=70 lines=9 & color 17 . . . and works great if it runs standalone. Now wh...
by PAB
17 Jul 2020 01:41
Forum: DOS Batch Forum
Topic: [SOLVED] Script closes when I press enter using set /p.
Replies: 2
Views: 218

Re: Script closes when I press enter using set /p.

By pressing enter, the variable is undefined. So when you are not using quotes the execution of the command becomes: if /i ==0 goto Exit_Program That is invalid syntax. The safe way to compare strings as you found out is to use quotes. Thank you Squashman, it is appreciated. I also solved that if l...
by PAB
16 Jul 2020 18:06
Forum: DOS Batch Forum
Topic: [SOLVED] Script closes when I press enter using set /p.
Replies: 2
Views: 218

[SOLVED] Script closes when I press enter using set /p.

Good evening, I hope everybody is OK and keeping SAFE ! I have a batch script that works well, except, if I DON'T enter a number and press < ENTER >, it exits the script. Here is the bit of code that I think is affecting it . . . setlocal EnableDelayedExpansion set "userinput=" set /p "userinput=>En...