[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 1997-09-02
14
Medium Priority
?
238 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
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 

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 200 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

650 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