# Dos: Set Help???????



## kj1983 (Oct 21, 2004)

Is there a way I can SET a variable to a mutiple String
not var though? for example:

SET myText = COOL

then later

I want to let the user to change it
to a different message by prompt so I try
SET /P myText=your message
it only works for 1 string only. how can I set it multiple string such "hello there"

Is there away I can get the user IP & computerName 
so like ECHO %TIME% show the time
I know I can use 'ipconfig' but it show tons of stuff.. I just want IP & computerName only!


----------



## Shadow2531 (Apr 30, 2001)

set myText=cool
set /p myText=your message:
type *hello there* and press enter
echo %myText%

Works fine and displays "hello there" for me.

To get just the ip address try

ipconfig /all | find "IP Address"

and for the computer name

ipconfig /all | find "Host Name"


----------



## kj1983 (Oct 21, 2004)

Shadow2531 said:


> set myText=cool
> set /p myText=your message:
> type *hello there* and press enter
> echo %myText%
> ...




```
@echo off
CLS
set myText=cool
set /p myText=your message:
echo %myText%
pause
```
this standalone batch script works fine..

but here is mine.. no works at work

```
:BEGIN
SET clientMsg=hi
ECHO -
ECHO -
SET /p clientMsg=YOUR MESSAGE :

IF '%clientMsg%'=='hi' goto EXIT2

:EXIT
ECHO  Your message " %clientMsg% " 
ECHO -
ECHO -
PAUSE

:EXIT2
EXIT
```
Is there a way it not show these output but only save it to a variable?
set ipNum = ?? <==save it here
so later I could just do this:
ECHO %ipNum% %time%


----------



## Shadow2531 (Apr 30, 2001)

This example should help.


```
:begin
@echo off
cls
set cm=init
set /p cm=What is your name? 
if "%cm%"=="quit" exit
echo/
echo Hi %cm% 
echo/
pause
goto :begin
```


----------



## Squashman (Apr 4, 2003)

echo %computername%


----------



## kj1983 (Oct 21, 2004)

oh thx.. now that what I wanted.

how about the ip?


LwdSquashman said:


> echo %computername%


----------



## Squashman (Apr 4, 2003)

kj1983 said:


> oh thx.. now that what I wanted.
> 
> how about the ip?


Umm, I am not quite sure what that means. That sentence makes no sense.

Here is your code. If you would have googled searched for it, you would have found it in 10 secons. That is all it took me.


```
for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
set ip=%ip: =%
```


----------



## kj1983 (Oct 21, 2004)

LwdSquashman said:


> Umm, I am not quite sure what that means. That sentence makes no sense.
> 
> Here is your code. If you would have googled searched for it, you would have found it in 10 secons. That is all it took me.
> 
> ...


echo %ip%

It does echo all the ip number.. it echo some weird ip address like
'fp90' that is all


----------



## Squashman (Apr 4, 2003)

English doesn't seem to be your first language. Post your output here. Which version of Windows are you using. It works fine for my on Windows XP.


----------



## kj1983 (Oct 21, 2004)

LwdSquashman said:


> English doesn't seem to be your first language. Post your output here. Which version of Windows are you using. It works fine for my on Windows XP.


I got Windows XP Pro.


```
:begin
@echo off
for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
set ip=%ip: =%
echo %ip%
pause
```
fe90
Press any key to continue ...


----------



## Squashman (Apr 4, 2003)

Let me see the output of ipconfig on your machine.


----------



## Squashman (Apr 4, 2003)

I don't know why it is not working on your machine. It works just fine on my machine. Would like to see the output of ipconfig on your machine. Try and see if this code works for you.


```
for /F "tokens=1-6 delims=:. " %%a in ('ipconfig ^| find "IP Address"') do set IPADDRESS=%%c.%%d.%%e.%%f
echo %IPADDRESS%
```


----------



## kj1983 (Oct 21, 2004)

code use:

```
:begin
@echo off
for /F "tokens=1-6 delims=:. " %%a in ('ipconfig ^| find "IP Address"') do set IPADDRESS=%%c.%%d.%%e.%%f
echo %IPADDRESS%
pause
```
fe80.5efe.64.455
Press any key to continue...


----------



## Shadow2531 (Apr 30, 2001)

@LwdSquashman

Thanks for the %computername% suggestion. I overlooked the obvious.

I'll test your loop with the ip address and see what I get.


----------



## Shadow2531 (Apr 30, 2001)

I tested with the loop in #12.

For me on WinXP, it prints out my IP address perfectly.


----------



## Squashman (Apr 4, 2003)

Shadow2531 said:


> I tested with the loop in #12.
> 
> For me on WinXP, it prints out my IP address perfectly.


Both of the loops I posted show my ip address correctly. I am not quite sure why his is giving him bogus output.

KJ, You dont perhaps have IPV6 installed on your computer?


----------



## kj1983 (Oct 21, 2004)

LwdSquashman said:


> Both of the loops I posted show my ip address correctly. I am not quite sure why his is giving him bogus output.
> 
> KJ, You dont perhaps have IPV6 installed on your computer?


ahh you're right I have ipV6 installed..


----------

