Solved

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

Posted on 1997-09-02
14
231 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
Comment Utility
Why would you want to pass it all as one parameter??
0
 
LVL 4

Expert Comment

by:nils pipenbrinck
Comment Utility
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
Comment Utility
Code:

  Uses DOS;
  Begin
    {$M 8192,0,0}
    Exec(GetEnv('ComSpec'),'/C mybatch.bat HELLO ALL!');
  End.
0
 

Author Comment

by:anderslee
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Expert Comment

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

Author Comment

by:anderslee
Comment Utility
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
Comment Utility
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
Comment Utility
I think I have partial solution.
0
 

Expert Comment

by:Johann091297
Comment Utility
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
Comment Utility
That was also my solution...
0
 
LVL 1

Expert Comment

by:eviltekk
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A procedure for exporting installed hotfix details of remote computers using powershell
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now