2Dalai
1. Watch the quantifiers, please. You did ask a general question using "at all". You should ask a specific question using "in this case" instead.
2. It's possible security issue:
* Users are not allowed to install any additional tool on any computer. Let them know how to use system tools in such cases.
* If "start" or "cmd" is needed in any batch, script, etc. which will be run many times, I prefer to use CMD with full path to prevent possible hijacking by malware.
[Solved] How to pass a parameter with a space (e.g. file name) ?
Moderators: white, Hacker, petermad, Stefan2
Re: How to pass a parameter with a space (e.g. file name) ?
Andrzej P. Wozniak
Polish subforum moderator
Polish subforum moderator
Re: How to pass a parameter with a space (e.g. file name) ?
2aequilibris
Correct. The whole quoted part is passed as one command line to cmd.exe, which splits it at spaces (and other delimiters). Hence the about 'C:\Program' not being found. To solve this you need to quote the entire thing again:It might even be necessary to use triple quotes, but I'm too lazy right now to test that.
BTW: if you already are in a batch file, you don't need cmd /c, unless you want to do something advanced or fancy.
2Usher
Please, read the entire context I'm writing about. This includes the code section I was refering to (and even part of the question), which made it clear that the use of CMD was not necessary at all (in this context). And, again, I already assumed that it's not about autostarts, so no need to take that into account.
2. Neither NirCmd nor Cmdow require installation. And, it may be a security risk to create a startup as user, so ... pick your poison. Although you're not wrong to use tools that come with Windows, it's good to know that there are (much) better tools out there, which often make things much easier and faster to get the job done.
Regards
Dalai
Correct. The whole quoted part is passed as one command line to cmd.exe, which splits it at spaces (and other delimiters). Hence the about 'C:\Program' not being found. To solve this you need to quote the entire thing again:
Code: Select all
cmd /c ""C:\Program Files (x86)\totalcmd9\TOTALCMD64.EXE" /O /R="PATH""
BTW: if you already are in a batch file, you don't need cmd /c, unless you want to do something advanced or fancy.
2Usher
Please, read the entire context I'm writing about. This includes the code section I was refering to (and even part of the question), which made it clear that the use of CMD was not necessary at all (in this context). And, again, I already assumed that it's not about autostarts, so no need to take that into account.
2. Neither NirCmd nor Cmdow require installation. And, it may be a security risk to create a startup as user, so ... pick your poison. Although you're not wrong to use tools that come with Windows, it's good to know that there are (much) better tools out there, which often make things much easier and faster to get the job done.
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Re: How to pass a parameter with a space (e.g. file name) ?
Really?Dalai wrote: ↑2019-02-21, 22:17 UTC 2aequilibrisCode: Select all
cmd /c ""C:\Program Files (x86)\totalcmd9\TOTALCMD64.EXE" /O /R="PATH""
Let's start here, in MS docs: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd
Which cmd version allows to use more than a single pair of quotation marks or to use them for non-exe part of command line? Some malware maybe?MS Docs wrote: Processing quotation marks
If you specify /c or /k, cmd processes the remainder of String, and quotation marks are preserved only if all of the following conditions are met:
You do not use /s.
You use exactly one set of quotation marks.
You do not use any special characters within the quotation marks (for example: & < > ( ) @ ^ | ).
You use one or more white-space characters within the quotation marks.
The String within quotation marks is the name of an executable file.
If the previous conditions are not met, String is processed by examining the first character to verify whether it is an opening quotation mark. If the first character is an opening quotation mark, it is stripped along with the closing quotation mark. Any text following the closing quotation marks is preserved.
Once again, be very careful with quantifiers, please.
Don't make a bigger mess, it's highly illogical, Captain Dalai.
Andrzej P. Wozniak
Polish subforum moderator
Polish subforum moderator
Re: How to pass a parameter with a space (e.g. file name) ?
Did you read and understand what MS writes? Did you TEST it? There is NOT a single executable in quotes, because the command line contains parameters to that executable. Furthermore, there's not ONE set of quotes but TWO, although they're not nested. Do you know which path is passed to TC in that command line and whether or not that contains any of the special characters MS mentions? I don't know, so I make sure the quotes are preserved by doubling them. So you see, only a minor part of conditions is met, and with only one pair of quotes, the command line just doesn't work because the first and last one are stripped, and that's why CMD looks for C:\Program[.exe].
Believe me when I say that I've been working for a long time with CMD and batch scripts, so I know what works and what doesn't.
It's highly illogical to ask in this thread related to this topc if something makes sense in conjunction with this topic? Strange point of view, sorry.Don't make a bigger mess, it's highly illogical, Captain Dalai.
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Re: [Solved] How to pass a parameter with a space (e.g. file name) ?
To pass a quoted parameter, without the quotes:
call x.bat "spacey parm"
inside x.bat
echo %~1
result:
spacey parm
call x.bat "spacey parm"
inside x.bat
echo %~1
result:
spacey parm