Elevated bat file with & or ^ in name dies

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
aGerman
Expert
Posts: 4748
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Elevated bat file with & or ^ in name dies

#16 Post by aGerman » 30 Sep 2014 10:15

You could open a cmd window.
E.g. "test1&test2&cmd .bat" (note the space next to cmd) would display
Der Befehl "G:\Documents\test1" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Der Befehl "test2" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. Alle Rechte vorbehalten.

C:\Windows\system32>

Because of the missing /k any following commands (like echo) would be ignored and show the same result.
Even if you would concatenate further commands via & operator it would stop with executing cmd.

Regards
aGerman

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Elevated bat file with & or ^ in name dies

#17 Post by penpen » 01 Oct 2014 10:32

foxidrive wrote:You can't have a / in a filename.
Ups :oops: i've forgotten that for just a second.

aGerman wrote:Because of the missing /k any following commands (like echo) would be ignored and show the same result.
Even if you would concatenate further commands via & operator it would stop with executing cmd.

In XP it is valid to use '-' instead of '/' for options, so how about a filename like "test & cmd -K echo awful.bat"?

penpen

aGerman
Expert
Posts: 4748
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Elevated bat file with & or ^ in name dies

#18 Post by aGerman » 01 Oct 2014 10:52

penpen wrote:In XP it is valid to use '-' instead of '/' for options, so how about a filename like "test & cmd -K echo awful.bat"?

That slipped my mind. It still stops with cmd. Something like "test & cmd^ -K^ echo(awful.bat" wouldn't work either.

Regards
aGerman

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Elevated bat file with & or ^ in name dies

#19 Post by penpen » 01 Oct 2014 11:18

OK. Thanks for testing (such a bug usage, in order to let the cmd window stay opended and let you read the error messages, would have been funny, or other funny things^^).

penpen

Post Reply