#102618 - 2003-07-08 12:32 AM
Shell and quotes
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
Shell and quotes
I need to know more
Any commandline freaks out there ?
Win2k+ Shell treats quotes in a different way than the previous M$ OS's
This is a valid Shell execution in Win9x + WinNT: Shell '%COMSPEC% /C "\\Server\Share\Oracle install\setup.exe" -responseFile "\\Server\Share\Oracle Install\Clientappuser.rsp" -nowelcome'
In Win2k+ Only one pair of quotes is allowed on the commandline by default
So how do i pass this to a Shell; Shell '"Path\Program" -Arg1 "Path\ParameterFile" -Arg2'
Where both: "Path\Program" And "Path\ParameterFile" Contains spaces
-Erik
|
|
Top
|
|
|
|
#102620 - 2003-07-08 12:47 AM
Re: Shell and quotes
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
If you do not use the "/C" switch then you can use two sets of quotes.
code:
Break On Shell '"c:\data\N F\kix32.exe" "c:\data\N F\junk.kix"'
c:\data\N F\junk.kix code:
Break On $dir=join(split(@DATE,"/"),".") + "_" + join(split(@TIME,":"),".") ? $dir
From CMD /?:
code:
If /C or /K is specified, then the remainder of the command line after the switch is processed as a command line, where the following logic is used to process quote (") characters:
1. If all of the following conditions are met, then quote characters on the command line are preserved:
- no /S switch - exactly two quote characters - no special characters between the two quote characters, where special is one of: &<>()@^| - there are one or more whitespace characters between the the two quote characters - the string between the two quote characters is the name of an executable file.
2. Otherwise, old behavior is to see if the first character is a quote character and if so, strip the leading character and remove the last quote character on the command line, preserving any text after the last quote character.
[ 08. July 2003, 00:49: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#102622 - 2003-07-08 01:29 AM
Re: Shell and quotes
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4567
Loc: USA
|
This is interesting...
I've done numerous bat files that contained two sets of quotes, and not once did I ever have any problems. However, I cannot say I ever used two sets of quotes AND two sets of parameters in the same command...
I can't think of a single test that I can use to duplicate what you are trying. I did try the following but it only contains one parameter, so while this does work, its not the same thing...
code:
break on shell '%comspec% /c xcopy "c:\test 1\table.htm" "c:\test 2\" /a' ? @serror ? @error
Just out of curiousity, have you tried the command in the dos shell to see what kind of error it gives you.
|
|
Top
|
|
|
|
#102624 - 2003-07-08 02:02 AM
Re: Shell and quotes
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4567
Loc: USA
|
While I would never recommend doing this, I have seen a "Working" batch file that contained quotes only around the directories that had spaces... the first time I saw it I was sure this could not work, but in fact it did...using your example...
code:
Shell '%COMSPEC% /C \\Server\Share\"Oracle install"\setup.exe -responseFile \\Server\Share\"Oracle Install"\Clientappuser.rsp -nowelcome'
Who knows... it might work?
|
|
Top
|
|
|
|
#102625 - 2003-07-08 02:02 AM
Re: Shell and quotes
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Shawn, is your DOS window COMMAND.COM or CMD.EXE?
|
|
Top
|
|
|
|
#102626 - 2003-07-08 02:06 AM
Re: Shell and quotes
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
quote: c:\data\scripts>%COMSPEC% /c "%SYSTEMROOT%\SYSTEM32\NOTEPAD.EXE" "%TEMP%\TEXT.TXT" The filename, directory name, or volume label syntax is incorrect.
|
|
Top
|
|
|
|
#102628 - 2003-07-08 02:13 AM
Re: Shell and quotes
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Well the SHELL command is calling %comspec%
code:
c:\data\scripts>C:\WINNT\system32\cmd.exe /c "%SYSTEMROOT%\SYSTEM32\NOTEPAD.EXE" "%TEMP%\TEXT.TXT" The filename, directory name, or volume label syntax is incorrect.
This is what the kixtart script is seeing.
|
|
Top
|
|
|
|
#102630 - 2003-07-08 02:47 AM
Re: Shell and quotes
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
That works on W2K - it is crazy!!
|
|
Top
|
|
|
|
#102631 - 2003-07-08 02:52 AM
Re: Shell and quotes
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I think that
SHELL '%COMSPEC% /C ""%USERPROFILE%\DESKTOP\NOTEPAD.EXE" "%TMP%\LOGON.LOG"" '
is more correct because the rules posted above state that the first and last quote will be stripped and the remaining text will be passed as the command string.
|
|
Top
|
|
|
|
#102632 - 2003-07-08 03:22 AM
Re: Shell and quotes
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Well done. So what we have here then is yet another thing that has to be wrapped in @INWIN and @DOS ? Wonder if this syntax is backward compatible with NT4 ...
-Shawn [ 08. July 2003, 03:23: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#102633 - 2003-07-08 03:27 AM
Re: Shell and quotes
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
let me check..back in a few minutes...
|
|
Top
|
|
|
|
#102634 - 2003-07-08 03:38 AM
Re: Shell and quotes
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
SHELL '%COMSPEC% /C ""C:\data\N F\NOTEPAD.EXE" "%TMP%\LOGON.LOG"" '
Shawn, this also seemed to work on my NT4 SP6a server.
Note: %TMP% is not a long file name however. [ 08. July 2003, 03:40: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#102635 - 2003-07-08 04:07 AM
Re: Shell and quotes
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
Minor observation.
Your path to NOTEPAD.EXE is wrong, but I think it does illustrate the intent of this thread.
An executable or associated program should be able to support the parameters discussed if properly '"quoted"'.
code:
SHELL '%COMSPEC% /C ""%systemroot%\SYSTEM32\NOTEPAD.EXE" "%USERPROFILE%\TEXT.TXT"" '
[ 08. July 2003, 04:30: Message edited by: NTDOC ]
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 811 anonymous users online.
|
|
|