[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 1997-09-02
14
Medium Priority
?
240 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
  • 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
If anyone asked you to network diagram of the internet, it was drawn in the form of a fluffy cloud which further became known as cloud computing. Popularly cloud computing is defined as workloads that run over the internet in a commercial provider’s…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

872 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