Search found 923 matches

by jeb
16 Jan 2020 07:17
Forum: DOS Batch Forum
Topic: Redirect text to a file (runas command result)
Replies: 13
Views: 174

Re: Redirect text to a file (runas command result)

Well, runas.exe doesn't write it's output to the standard stream or error stream, so it can't be redirected that way. This can't be correct, I tested it with Win10 10.0.17134.1184 and I can redirect it without problems. And also with Win7 6.1.7601 the redirection works. In both cases the content of...
by jeb
15 Jan 2020 15:53
Forum: DOS Batch Forum
Topic: Redirect text to a file (runas command result)
Replies: 13
Views: 174

Re: Redirect text to a file (runas command result)

How it fails, what is the error message or the unexpected behavior?

Do you can write files in the current directory at all?

Did you test it on the command line or somewhere inside a batch file?

Which Wndows version do you use?
by jeb
15 Jan 2020 01:20
Forum: DOS Batch Forum
Topic: Redirect text to a file (runas command result)
Replies: 13
Views: 174

Re: Redirect text to a file (runas command result)

Hi avizee,

I tested

Code: Select all

echo( | runas /user:asdf "echo %date%" > test.txt
It works, the complete text is in test.txt.
The only difference to your first example, is the enclosing of echo %date% into quotes
by jeb
09 Jan 2020 00:02
Forum: DOS Batch Forum
Topic: cmd.exe chars needing quotes, and escaping redirection handles
Replies: 6
Views: 267

Re: cmd.exe chars needing quotes, and escaping redirection handles

Hi Dave, interessting. 1) Special characters listed in cmd help ... If completion is enabled with the /F:ON switch, the two control characters used are Ctrl-D for directory name completion and Ctrl-F for file name completion. :o Dind't know this, nor read this before. But CTRl-F doesn't work for me ...
by jeb
31 Dec 2019 03:45
Forum: DOS Batch Forum
Topic: Batch file macro and SNAKE.BAT
Replies: 2
Views: 265

Re: Batch file macro and SNAKE.BAT

Hi Meerkat, the parenthesis are necessary in macros, when you want to use the %\n% for multiple lines. That's because a raw line feed outside parenthesis stops the parser and the remaining stuff will be dropped. You can't compare it to the code from Snake.bat, as the code you shown is part of a func...
by jeb
19 Nov 2019 16:10
Forum: DOS Batch Forum
Topic: bat obfuscation with set ***=****
Replies: 5
Views: 1477

Re: bat obfuscation with set ***=****

It's possible to expand a variable, begining with an asterix.

Code: Select all

set **.=SSS
setlocal DisableExtensions
echo %**.%
jeb
by jeb
02 Oct 2019 00:34
Forum: DOS Batch Forum
Topic: Enabling the internal debug outputs of cmd.exe
Replies: 17
Views: 14758

Re: Enabling the internal debug outputs of cmd.exe

No, it still works. At least with Microsoft Windows [Version 10.0.17134.1006] By using some nested FOR /F loops, I accidentally activated the debug mode. @echo off set "FOR_CMD=FOR /F "tokens=1-31" %%1 in ("jeb jeb") DO ^" %FOR_CMD% %FOR_CMD% %FOR_CMD% %FOR_CMD% %FOR_CMD% %FOR_CMD% %FOR_CMD% %FOR_CM...
by jeb
01 Oct 2019 14:28
Forum: DOS Batch Forum
Topic: Some tricks with undefined variables
Replies: 3
Views: 5886

Re: Some tricks with undefined variables

@jfl Nice ECHO! macro I think 4) is useful when you want the definition of a macro to change depending on the state of some variable, for example if DEBUG is defined (enabled) or not. It allows incorporation of conditional text without creation of temp variables or staged definition 1- Me too, nice...
by jeb
01 Oct 2019 13:33
Forum: DOS Batch Forum
Topic: Enabling the internal debug outputs of cmd.exe
Replies: 17
Views: 14758

Re: Enabling the internal debug outputs of cmd.exe

There is still hope :D
Last week, I accidentially activated the debug outputs on Win10, by nesting some FOR /F loops (some hundreds).

Tomorrow, I will try to search the batch files and reproduce it.
by jeb
13 Sep 2019 03:33
Forum: DOS Batch Forum
Topic: Some tricks with undefined variables
Replies: 3
Views: 5886

Some tricks with undefined variables

Hi, 1) Default values undefined variables are more or less empty variables, but only inside batch files. The difference for batch files and command line echo var: %undefinedVar% Output when executed on the command line: var: %undefinedVar% Output when executed in a batch file var: But even in batch ...
by jeb
07 Sep 2019 02:44
Forum: DOS Batch Forum
Topic: CALL myBatch.bat can return to the wrong place
Replies: 4
Views: 2312

Re: CALL myBatch.bat can return to the wrong place

I found one useful behaviour for the "missing stack entry". It works nearly the same as a GOTO, but there is one difference when it's in a command block or there are appended commands. A GOTO discards the other commands of a block and all appended commands (by &) @echo off echo [%0]: Before calling ...
by jeb
07 Sep 2019 02:15
Forum: DOS Batch Forum
Topic: CALL myBatch.bat can return to the wrong place
Replies: 4
Views: 2312

Re: CALL myBatch.bat can return to the wrong place

Hi siberia-man, thanks for the interesting link, I was able to understand the posts, thanks to google translate. You described the ? and * for labels, there both characters works as expected, like any other charcter. But the key difference is using them not in a lable, instead use them in a called f...
by jeb
06 Sep 2019 11:52
Forum: DOS Batch Forum
Topic: CALL myBatch.bat can return to the wrong place
Replies: 4
Views: 2312

CALL myBatch.bat can return to the wrong place

Hi, while refactoring my macro library, I found an unknown behaviour of the CALL/return file logic. :!: It fails when in the called batch file path at least one question mark or asterix is embedded. It seems a little bit related to the (goto) 2> nul glitch. First a sample, showing the normal behavio...
by jeb
06 Sep 2019 11:05
Forum: DOS Batch Forum
Topic: Closing parenthesis prevents escape of subsequent special character operator
Replies: 33
Views: 11281

Re: Closing parenthesis prevents escape of subsequent special character operator

Hi sst, I'm impressed by your analysis/debugging. :o :!: It explains so much. Now, I understand why the REM trick to gather the arguments works so good, and why it fails with multiline input. The REM parser will read the first token(GeToken) and compares it against "/?". If the token is "/?" it sets...
by jeb
29 Aug 2019 06:10
Forum: DOS Batch Forum
Topic: Replace "!" in a variable value when delayed expansion is on
Replies: 7
Views: 2947

Re: Replace "!" in a variable value when delayed expansion is on

Hi Penpen,

you are right. The Call is superfluous, I cpoied it from macro code.

@GCRaistlin
No it's not possible to use delayed expansion to replace a single bang, only when the bang is precede with other charactets.