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

2

What's the difference between using - and / in the CMD for example in the command:

shutdown -s

or

shutdown /s
    
asked by anonymous 15.08.2017 / 19:52

2 answers

2

Originally, DOS / Windows systems use / to supplement commands, while on other systems such as Unix-based systems, - is used to complement commands. However, the / is only a convention (eg, ipconfig /all ), allowing the use of parameters via - . Usually the use of - as a parameter serves more as a way to make code closer to POSIX systems.

    
15.08.2017 / 20:57
0

This is a feature of the shutdown command, the program interprets as you want, for example if you create a program in Python (3):

import sys

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

And so call on 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

In other words, the program internally receives as described for each spacing, but it is the one that deals internally, so it will probably identify /s and -s as being the same, if desired, using if or switch or what the language supports.

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

    
15.08.2017 / 19:56