Search found 19 matches

by PiotrMP006
2024-Jan-11, 6:23 am
Forum: Windows CMD Shell
Topic: stringlength.cmd - just created - for anybody who can use it
Replies: 2
Views: 13585

Re: stringlength.cmd - just created - for anybody who can use it

Hi Why is there a " # " sign at the beginning of the code set "s= # !%~1!"? goto:eof :strlen StrVar [RtnVar] setlocal EnableDelayedExpansion set "s=#!%~1!" set "len=0" for %%N in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do ( if "!s:~%%N,1!" neq ...
by PiotrMP006
2024-Jan-10, 2:22 pm
Forum: Windows CMD Shell
Topic: How to replace the string "ABCDE" with the string "00000" of the same length?
Replies: 1
Views: 1300

How to replace the string "ABCDE" with the string "00000" of the same length?

Hi

How to replace the string "ABCDE" with the string "00000" of the same length?

ex

ABCDE
000000

ABCDEFG
000000000
by PiotrMP006
2024-Jan-10, 8:03 am
Forum: Windows CMD Shell
Topic: How to replace the script name %~n0 with a string of "-" characters of length %~n0?
Replies: 2
Views: 1559

How to replace the script name %~n0 with a string of "-" characters of length %~n0?

Hi

How to replace the script name %~n0 with a string of "-" characters of length %~n0?

Code: Select all

ex. %~n0 = Test.bat

How do I change "Test.bat" to the string "---------" ?

Test.bat
--------
by PiotrMP006
2023-Dec-21, 6:35 am
Forum: Windows CMD Shell
Topic: Why for loop wmic get processid return an extra invalid value?
Replies: 0
Views: 7832

Why for loop wmic get processid return an extra invalid value?

Hi Why for loop wmic get processid return an extra invalid value? for /f "usebackq skip=1 delims=" %%a in (`wmic process where "name='cmd.exe' and commandline like '%%%~n0%%'" get processid 2^>nul`) do echo %%a The first returned value %%a is the real processid The second returne...
by PiotrMP006
2023-Dec-18, 6:22 am
Forum: Windows CMD Shell
Topic: How can a batch lower the priority ONLY of the cmd that runs it?
Replies: 1
Views: 2339

How can a batch lower the priority ONLY of the cmd that runs it?

Hi

How can a batch lower the priority ONLY of the cmd that runs it?

Why isn't this code working?

Code: Select all

wmic process where "name='cmd.exe' and commandline like '%%scriptname%%'" call setpriority "high"
Please help
by PiotrMP006
2023-Dec-15, 2:56 pm
Forum: Windows CMD Shell
Topic: How to make an underscore variable "-----" with the length of the argument variable?
Replies: 2
Views: 2876

How to make an underscore variable "-----" with the length of the argument variable?

How to make an underscore variable "-----" with the length of the argument variable?

ex.

Code: Select all

Script Name
-----------
Please help
by PiotrMP006
2023-Jul-26, 1:26 pm
Forum: Windows CMD Shell
Topic: How to detect in 7-Zip fatal error #2 "Wrong password" in windows batch?
Replies: 2
Views: 10755

How to detect in 7-Zip fatal error #2 "Wrong password" in windows batch?

Hi

How to detect in 7-Zip fatal error #2 "Wrong password" in windows batch?

Code: Select all

ERROR: a.7z : Cannot open encrypted archive. Wrong password?
by PiotrMP006
2023-Jul-23, 1:51 pm
Forum: Windows CMD Shell
Topic: Does "endlocal" close all instances of "setlocal"?
Replies: 6
Views: 10424

Does "endlocal" close all instances of "setlocal"?

Does "endlocal" close all instances of "setlocal"?

ex

Code: Select all

setlocal enabledelayedexpansion enableextensions
set name1=1

setlocal disabledelayedexpansion enableextensions
set name2=2

setlocal enabledelayedexpansion enableextensions
set name3=3

endlocal
by PiotrMP006
2023-Jul-18, 8:23 am
Forum: Windows CMD Shell
Topic: How to enter a NULL character?
Replies: 1
Views: 8725

How to enter a NULL character?

How to enter a NULL character?
by PiotrMP006
2023-Jul-12, 8:51 am
Forum: Windows VBScript
Topic: How to quickly check if a file has 1 or more lines of text?
Replies: 1
Views: 10888

How to quickly check if a file has 1 or more lines of text?

Hi

How to quickly check if a file has 1 or more lines of text?

I'm not talking about counting all lines of text, just a quick check if the file has 1 or more lines.

Please help me