Solved

How to call batch with %1="Hello All"

Posted on 1997-09-02
14
236 Views
Last Modified: 2010-04-16
If I call a batch , I can pass parameter as "BATCH Hello All"  But DOS will treat %1='hello' and %2='all'

How do I force it to take 'hello all' for %1 ??
0
Comment
Question by:anderslee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +5
14 Comments
 
LVL 2

Expert Comment

by:kellyjj
ID: 1215518
Why would you want to pass it all as one parameter??
0
 
LVL 4

Expert Comment

by:nils pipenbrinck
ID: 1215519
That's easy.

you can pass "hello all" as a parameter and the command shell will remove the " and don't split the two words.


0
 

Expert Comment

by:hgnutzmann
ID: 1215521
Code:

  Uses DOS;
  Begin
    {$M 8192,0,0}
    Exec(GetEnv('ComSpec'),'/C mybatch.bat HELLO ALL!');
  End.
0
Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

 

Author Comment

by:anderslee
ID: 1215522
Exec(GetEnv('ComSpec'),'/C mybatch.bat HELLO ALL!');

(1) your code should read:
     Exec(GetEnv('ComSpec'),'/C mybatch.bat "HELLO ALL!"');
(2) DOS will treat  "HELLO ALL!" as %1, including "

0
 
LVL 10

Expert Comment

by:rbr
ID: 1215523
Space are treated under DOS to sperate each word. So you need another character for this. The _ (underscore) is made for this.

0
 

Author Comment

by:anderslee
ID: 1215524
If a _ is made for the space,
then I have no problem at all??!!!

Is_this_sentence_looks_good_to_you_at_all??
0
 
LVL 10

Expert Comment

by:rbr
ID: 1215525
The problem is you can't force DOS tho treat Hello World is one word. You must use another character. Or you have to use "HELLO World" with the ".
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215526
Anderslee - Do you pass the "Hello world" as plain text argument?
0
 

Author Comment

by:anderslee
ID: 1215527
There may not be a method through command line, but there's
gotta be a way.
At least I encounter one program that can do that.

0
 
LVL 10

Accepted Solution

by:
rbr earned 100 total points
ID: 1215528
You can set an enviroment variable set TEXT=Hello World. This varibale can be used in the batch file.
echo %TEXT

0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215520
I think I have partial solution.
0
 

Expert Comment

by:Johann091297
ID: 1215529
charcter 255 looks exactly like a space and is not seperated when u send it as a parameter !

so instead of sending the parameter as
  'Hello'+chr(32)+'All!'    {where chr(32) is space}
send
  'Hello'+chr(255)+'All!'   {where chr(255) looks like space
                             but not splitted like space}

now, this should work
  Exec(GetEnv('ComSpec'),'/C mybatch.bat HELLO'+chr(255)+'ALL!');
0
 
LVL 1

Expert Comment

by:FuzzyLogic
ID: 1215530
That was also my solution...
0
 
LVL 1

Expert Comment

by:eviltekk
ID: 1215531
set temp=
:start
if e%1==e goto doneshift
set temp=%temp% %1
shift
goto start
if e%1==e goto doneshift

:doneshift


rem your batch...your data is in the %temp%, or you call the rem batch again with that way: 1.Bat %temp%


 
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We take a look at some of the most common obstacles that IT teams run into as they work relentlessly to keep all the alarms and sirens from going off at once.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question