Search found 17 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: 14635

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: 1745

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: 4064

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: 8453

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: 2731

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: 3296

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: 10984

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: 10616

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: 8829

How to enter a NULL character?

How to enter a NULL character?
by PiotrMP006
2023-Jun-13, 2:22 pm
Forum: Windows CMD Shell
Topic: How to convert argument list to skip first argument???
Replies: 1
Views: 7491

How to convert argument list to skip first argument???

Hi How to convert argument list to skip first argument? %* = "C:\7-Zip Test\" "File&Test 1.txt" "File&Test 2.txt" "File&Test 3.txt" After conversion, this should be the argument list %filelist% = "File&Test 1.txt" "File&Test ...