What is the difference between " - " and " / " in CMD commands

Asked

Viewed 231 times

3

What’s the difference of using the - and the / in the CMD for example in the command:

shutdown -s

or

shutdown /s

2 answers

4


Originally, on DOS/Windows systems, / to complement the commands, whereas in other systems such as Unix-based systems, the - to complement the commands. However / is only a convention( P.ex.: ipconfig /all), enabling the use of parameters via -. Generally the use of - as parameter serves more as a way to make code closer to POSIX systems.

1

That’s a characteristic of command shutdown, the program interprets as you wish, for example if you create a program in Python (3):

import sys

print ("\n".join(sys.argv))

And call it that at the terminal or cmd:

python arquivo.py -foo -bar -baz

will print this:

-foo
-bar
-baz

If you do this

python arquivo.py /foo /bar /baz

Will print this:

/foo
/bar
/baz

That is the program internally gets as described for each spacing, but it is the one who treats internally, so it will probably identify /s and -s as being the same, if desired, using if or switch or what language can bear.

The shutdown specifically probably supports both for ease and/or portability issues between Windows versions, it is not necessarily a programming problem, but rather a personal choice of who developed it (microsoft ?!)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.