Search found 35 matches

by Maylow
21 Apr 2021 11:24
Forum: DOS Batch Forum
Topic: Delete specified multiple lines of a not in use batch file through another batch file?
Replies: 4
Views: 5377

Re: Delete specified multiple lines of a not in use batch file through another batch file?

If the file you want to change is that explicit with data, the following code would accomplish the task: @echo off setlocal enableDelayedExpansion set findstr.Ia=0 set findstr.Ib=0 for /f "usebackq tokens=* delims=^" %%b in ( `type subject.cmd`) do ( echo("%%~b"|findstr /rc:"start notepad.exe" 2>nul...
by Maylow
21 Apr 2021 11:04
Forum: DOS Batch Forum
Topic: Start batch files at startup...
Replies: 2
Views: 3397

Re: Start batch files at startup...

Probably because by default access to "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\" is restricted for security reasons. You can copy to the user startup folder %APPDATA%\Microsoft\Windows\Start Menu\Programs\StartUp\, no problem. Code snippet of batch script that copies itself to u...
by Maylow
21 Apr 2021 10:55
Forum: DOS Batch Forum
Topic: Please review my code
Replies: 1
Views: 2302

Re: Please review my code

At first sight, I'd suggest an improvement would be to verify/validate data before assigning to variables. For example, the output of your first wmic statement contains multiple lines, first line contains name of field, second line contains data, third line contains empty space. Is uppose you only w...
by Maylow
19 Apr 2021 19:02
Forum: DOS Batch Forum
Topic: Proof of concept: Model, View, Controller and Interfaces
Replies: 0
Views: 38109

Proof of concept: Model, View, Controller and Interfaces

I've written a script containing a macro which acts like the 'Implements' statement in many OOP supported languages. As proof of concept, I've written 6 other scripts which demonstrate the usage of a Model, View, Controller and Interface. Apart from the concept Interface, no other OOP features are u...
by Maylow
02 Aug 2020 15:26
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 11913

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

Success! Thanks to Jeb for the clear explanation and solution provided :D I adjusted the code in the examples and got results as expected in all situations. callee.cmd: @echo off set "$PERCENT=%%%%~$=_p1_FOR-variable_DOLLAR_is_required_while_MACRO_DEFINITION_=:$" FOR %%$ in (DOLLAR) DO ( set "__macr...
by Maylow
02 Aug 2020 14:59
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 11913

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

@All, many thanks for responding and giving a lot of information and explanation! @T3RRY, your hints and Jeb's explanation make me wondering, i am going to experiment with the suggestions posted here. @Jeb ahh i see, thanks for the clear explanation. I will try to implement the suggestions and let y...
by Maylow
02 Aug 2020 10:33
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 11913

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

Interesting thing i remembered: FOR command also and even accepts unicode characters as variables.

Code: Select all

for %%È in (test) do echo(%%È
This works.
(using È character with Alt+0456 on numeric keypad)

However, it does not solve the situation.
by Maylow
02 Aug 2020 09:36
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 11913

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

I don't want to pass the value of a for variable to another script or subroutine, far from that. I want the FOR variable to be left alone when defining the macro. To resummarize, i have accomplished: set __call=for %%A in set "__macro= do (if /i "%%~A" equ "_some value" (echo("some value" detected) ...
by Maylow
02 Aug 2020 06:56
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 11913

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

Thus far, the work-around is:
Either i don't define macros within FOR loops, or have such scripts called per line instead of within FOR loops.

Thanks for thinking with me by the way, appreciated! :D
by Maylow
02 Aug 2020 06:53
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 11913

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

Ah yea :) thought about that too. But chicken-egg problem: Macros are called with a caller macro which uses %%A. Macro definitions use %%A as argument input. The library scripts are called using a macro which uses %%A. Some library scripts define macros wihtin a FOR loop (with whatever %%*, that doe...
by Maylow
02 Aug 2020 06:46
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 11913

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

By the way, about: Remember, FOR variables are single-letter, case sensitive, global, and you can't have more than 52 total active at any one time. The documentation is actually incorrect about itself. The 52 characters limitation ought to be based on a-z A-Z. However, 0-9 and other characters like ...
by Maylow
02 Aug 2020 06:38
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 11913

Re: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

I see. I know that they are global. The external scripts are, what i call, libraries with macro definitions. That's the reason why they are called externally, to load the macro definitions. These libraries are only called once, to load their macro definitions. And delayed expansion is not acceptable...
by Maylow
01 Aug 2020 17:40
Forum: DOS Batch Forum
Topic: FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop
Replies: 15
Views: 11913

FOR variable %%A in macro definition gets overridden when script is called by other script within FOR loop

Situation description: I have some scripts which define macros within FOR loops and these macros are called using FOR loops. I have some other scripts which call these scripts within FOR loops. When doing so, i noticed that FOR variables within macro definitions are overridden. I have a work-around,...
by Maylow
20 Oct 2019 07:10
Forum: DOS Batch Forum
Topic: I need an example
Replies: 2
Views: 9010

Re: I need an example

Not sure what you want or how you want it exactly. More specifications of your goal might help. What do you mean with 'the guy'? Is this a set of characters which together look like a guy, like in ASCII art? How do you see 'control'? As in 'move' the set of characters? There are many ways to achieve...
by Maylow
09 Oct 2019 22:15
Forum: DOS Batch Forum
Topic: Remove Microsoft header from cmd, for example when executing code from alternate data stream
Replies: 10
Views: 20590

Re: Remove Microsoft header from cmd, for example when executing code from alternate data stream

I have read about the limitations of alternate data streams, such as NTFS required, not transportable (upload/download/email) and such. Fortunately this is not a problem for the project. NTFS is a requirement of the project because other features of NTFS are also used (file compression/encryption). ...