Useless tips in DOS !!!

Useless tips?

This page shows some, er, let's call it "unexpected" behaviour of various DOS commands.
Many will be of no practical use -- hence this page's title -- but it may be fun to experiment with them.

DOSKEY and SET /P

A tip by Padmanabha Holla:
If you have a doskey macro defined and if you input that macro string as input for any SET /P varname= command, later on varname contains the alias of your input, not your input!
C:\>DOSKEY fit=dir
C:\>DOSKEY xla=cls
C:\>SET /P Test=Macro1?
Macro1?xla
C:\>ECHO %Test%
cls
C:\>SET /P Test=Macro2?
Macro2?fit
C:\>ECHO %Test%
dir
C:\>SET /P Test=Macro3?
Macro3?DoesNotExist
C:\>ECHO %Test%
DoesNotExist
C:\>
Thanks Padmanabha

+ Prefix

Adding a plus sign before a command does some pretty weird things in DOS.
Try this for example, and watch the path in your prompt:
C:\>+MD

C:\>+CD

C:\D>CD..

C:\>+RD

C:\>+CD
Directory not found

C:\>
It seems that, for example, +COPY C: is interpreted as COPY Y C:
+DIR will be interpreted as DIR R
The effect of the + before a DOS command is that the last character of the DOS command is inserted as the first command line argument.
This works for COMMAND.COM's "internal commands" only.
As I said, pretty weird and pretty useless.
Unless, of course, you are looking for a way to make your batch files hard to understand.
(Thanks for Günther Brunthaler for helping me work out a proper description of the effect).

ATTRIB

ATTRIB,
Note the comma.
Removes all attributes from all files in the current directory, like
ATTRIB *.* -S -H -R -A
Should work in MS-DOS 5 and 6.* and IBM DOS 5 through 7.

Escape Characters

Both NT and OS/2 offer the ˆ (caret) as an escape character for command lines. Both will display:
Usage: ABC.BAT <drive:>
when you issue the command:
ECHO Usage: ABC.BAT ˆ<drive:ˆ>
Both NT and OS/2 show some unexpected behavior when the escape character is used as the last character of the command line.
The first time I heard about this strange behavior was in a post from Mark Stang in the alt.msdos.batch news group.
Let's take this simple batch file, for example:
SET DATE=ˆ
12/12/99
ECHO Date=%DATE%
In NT, the resulting output would look like this:
Date=12/12/99
That makes this trick really useful in NT. The second line, containing the date, could come from the DATE/T command in another batch file, for example.
In OS/2, however, the output from that same batch file looks like this:
Date=
However, the command SET DATE will display:
Date=
     12/12/99
The only way to make OS/2 display the value of the DATE variable is:
SET DATE| FIND /V "DATE="
(No space between DATE and | allowed)
In NT, the caret at the end of the line is interpreted as "skip the following linefeed".
In OS/2, the SET command interprets the caret as an escape character for the following linefeed, so the variable will contain a linefeed. A pity it cannot be displayed using %variable%, that would have allowed multiple lines of text in a single variable.
Right now, in OS/2, the only use I could think of is for hiding variables.
If you did  find any other way to use this "hidden feature", please send it to my e-mail address.

SET Quirk

Besides the "long list of known problems" with NT's SET /A switch, it has some "unknown" features too.
I haven't found a useful application of the following features yet, maybe you can think of some.
These features were mailed to me by Ken Gould. Thanks.
The common way to use the /A switch is like this:
SET /A variable = mathematical expression
If, however, all you need to do is display the result of the expression on screen, you can use SET like this:
SET /A mathematical expression
For example:
SET /A 75 / 5
will display 15 on screen.
An extra "bonus" feature is the way the result of the expression is displayed: without a carrige return/line feed!
Try this:
(SET /A 75 / 5) > TEST.TXT
The file TEST.TXT will contain one line with nothing but the number 15 and no carriage return/line feed. Check the file size, it will be only 2 bytes.
Ken Gould also mailed me a trick to use when you do want a carriage return/line feed at the end:
(SET /A 75 / 5) | MORE > TEST.TXT
TEST.TXT's size will now be 4 bytes, due to the carriage return/line feed pair added by MORE.
If you prefer internal commands, use this instead:
(SET /A 75 / 5) > TEST.TXT
ECHO.>> TEST.TXT
This SET /A feature can be used as a command line calculator.
Don't, however, expect it to work in the following batch file:
SET /A %1 %2 %3 %4 %5 %6 %7 %8 %9
nor in:
SET /A %*
Calling this batch file with the arguments 12 + 3 will return nothing.
This behaviour seems rather inconsitent.
What does work is this:
SET /A Result = %*
SET Result
Both Windows 2000 and XP show the same results.
This tip was shown to me by Chris Moore. Thanks.

ECHO

Robert Van Etta reported some very odd behaviour of the ECHO command in Windows 2000/XP/Server 2003. Type:
ECHO ˆ
at the command line (doesn't work in batch files) and you will be prompted for "More?".
Type in any text, followed by the Enter key, and it will be echoed again.
To store this text into a file, type:
> MYINPUT.TXT ECHO ˆ
Too bad it won't work in a batch file...

Create Empty Files

to create an empty (zero bytes) file I always used:
TYPE NUL > new_empty_file_name
Robert Van Etta showed me an even shorter command:
CD.> new_empty_file_name

IF ERRORLEVEL

Benny Pedersen has listed some pretty weird but definitely very useful behavior of the IF ERRORLEVEL command on his DOS/batch page.

1 comments:

Are you Seeking for the Best Legit Professional Hackers online??❓💻💻💻
Congratulations Your search ends right here with us. 🔍🔍🔍🔍

🏅ALEXGHACKLORD is a vibrant squad of dedicated online hackers maintaining the highest standards and unparalleled professionalism in every aspect.
We Are One Of The Leading Hack Teams in The United States🇺🇸🇺🇸 With So many Accolades From The IT Companies🏆🏅🥇. In this online world there is no Electronic Device we cannot hack. Having years of experience in serving Clients with Professional Hacking services, we have mastered them all. You might get scammed for wrong hacking services or by fake hackers on the Internet. Don't get fooled by scamers that are advertising false professional hacking services via False Testimonies, and sort of Fake Write Ups.❌❌❌❌

* ALEXGHACKLORD is the Answers to your prayers. We Can help you to recover the password of your email, Facebook or any other accounts, Facebook Hack, Phone Hack (Which enables you to monitor your kids/wife/husband/boyfriend/girlfriend, by gaining access to everything they are doing on their phone without their notice), You Wanna Hack A Website or Database? You wanna Clear your Criminal Records?? Our Team accepts all types of hacking orders and delivers assured results to alleviate your agonies and anxieties. Our main areas of expertise include but is never confined to:

✅Website hacking 💻,✅Facebook and social media hacking📲, ✅Database hacking, Email hacking⌨️, ✅Phone and Gadget Hacking📲💻,✅Clearing Of Criminal Records❌ ✅Location Tracking✅ Credit Card Loading✅ and many More✅

🏅We have a trained team of seasoned professionals under various skillsets when it comes to online hacking services. Our company in fact houses a separate group of specialists who are productively focussed and established authorities in different platforms. They hail from a proven track record and have cracked even the toughest of barriers to intrude and capture or recapture all relevant data needed by our Clients. 📲💻

🏅 ALEXGHACKLORD understands your requirements to hire a professional hacker and can perceive what actually threatens you and risk your business⚔️, relationships or even life👌🏽. We are 100% trusted professional hacking Organization and keep your deal entirely confidential💯. We are aware of the hazards involved. Our team under no circumstances disclose information to any third party❌❌. The core values adhered by our firm is based on trust and faith. Our expert hacking online Organization supports you on time and reply to any query related to the unique services we offer. 💯

🏅ALEXGHACKLORD is available for customer care 24/7, all day and night. We understand that your request might be urgent, so we have a separate team of allocated hackers who interact with our Clients round the clock⏰. You are with the right people so just get started.💯✅

✅CONTACT US TODAY VIA:✅
📲 ALEXGHACKLORD@GMAiL. COM 📲

Reply

Reply

Post a Comment