Powershell window9/21/2023 For instance, in Windows XP / newer you can run: However, when you run commands directly (e.g., from the "Run" menu option of the Start menu), the Windows operating system may look for commands in some additional places. Maybe some people think that they are helping matters by causing the PATH environment variable to be set. It's really not needed when people know what they're doing.Īs for the second bullet point I provided, which is to set environment variables, that's also something that you're not actively doing in this particular case. Having a more flexible example may be useful for some people. The only benefit I'm seeing to going through the extra step of typing " CMD /C" is to provide an example which will be useful if somebody decides to try modifying an example to run a command line " DIR" or " COPY". In this case, you can just run powershell just as easily as " CMD /C powershell", so you gain no benefit from the unnecessary " CMD /C". However, in this scenario, if I try to run " CMD /C DIR", then that will work, because Windows will look for an executable named " CMD", and will find that, and then CMD will end up successfully running the " DIR" command which is an internal part of the " CMD" command. (Supported extensions can be seen by running " ECHO %PATHEXT%".) Windows will fail to run that command since there is no " DIR.EXE", " DIR.BAT", or " DIR" file ending with another supported extension. For example, if I use the external command PSEXEC (downloaded from SysInternals), and try to run " DIR" on a remote computer, then Windows will try to run the " DIR" command. So, there can, in some cases, be a time when using " CMD /C" is useful. However, in this case, neither of those benefits are gained. Sets environment variables, such as the PATH variable.Using CMD has the following effects which can commonly be good in some cases: People might think there is a good reason to do this. In fact, the only real effect that happens is to slow things down.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |