Jump to content
Sign in to follow this  
adr3nal1n

_rundos spaces in variables passed to dosbatch as a parameter

Recommended Posts

adr3nal1n

Hi,

I am hoping someone can help with this query,

Here is a small test that I cannot get to work as it is not passing any spaces in the $name variable back to dos as a parameter (in this instance %1)

Is this to do with quotes or am I missing something else?

Autoit script as follows...

#include <Process.au3>

$email = InputBox("title", "Enter your email address", "")

$name = InputBox("title", "Enter your full name", "")

_RunDOS("d:\test.cmd " & $name & " " & $email)

Dos Batch file as follows...

set name=%1

set email=%2

echo Your name is %name% and your email address is %email%

:eof

Thanks in advance for your help.

Lee.

Share this post


Link to post
Share on other sites
azure

Hi,

I am hoping someone can help with this query,

Here is a small test that I cannot get to work as it is not passing any spaces in the $name variable back to dos as a parameter (in this instance %1)

Is this to do with quotes or am I missing something else?

Autoit script as follows...

#include <Process.au3>

$email = InputBox("title", "Enter your email address", "")

$name = InputBox("title", "Enter your full name", "")

_RunDOS("d:\test.cmd " & $name & " " & $email)

Dos Batch file as follows...

set name=%1

set email=%2

echo Your name is %name% and your email address is %email%

:eof

Thanks in advance for your help.

Lee.

Probably. Any spaces would throw off your variables.

Try this:

#include <Process.au3>
$email = InputBox("title", "Enter your email address", "")
$name = InputBox("title", "Enter your full name", "")
_RunDOS('d:\test.cmd "' & $name & '" "' & $email & '"')

Share this post


Link to post
Share on other sites
adr3nal1n

Thanks very much Azure for the revised Autoit code, the variables containing spaces are now passed to dos as parameters containing spaces but the quotes surrounding the parameters were also present in the echo output from the dos batch so I have tweaked the dos batch to remove the quotes, new dos batch code as shown below.

Hopefully this test exercise will help others with similar queries. Now I properly understand the correct syntax for _rundos I can get to work on the real script I want to add a front end gui to.

New dosbatch code...

set name=%~1

set email=%~2

echo Your name is %name% and your email address is %email%

:eof

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×