There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer ipod itunes laptop malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan upgrade usb virtumonde virus vista vista 32-bit windows windows xp winxp wireless
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Dos: Set Help???????


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
kj1983's Avatar
Junior Member with 15 posts.
 
Join Date: Oct 2004
21-Oct-2004, 04:52 AM #1
Dos: Set Help???????
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's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
21-Oct-2004, 09:26 AM #2
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's Avatar
Junior Member with 15 posts.
 
Join Date: Oct 2004
21-Oct-2004, 02:39 PM #3
Quote:
Originally Posted by Shadow2531
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"


Code:
@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
Code:
: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's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
21-Oct-2004, 03:03 PM #4
This example should help.

Code:
: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's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Oct-2004, 09:26 PM #5
echo %computername%
kj1983's Avatar
Junior Member with 15 posts.
 
Join Date: Oct 2004
21-Oct-2004, 09:39 PM #6
oh thx.. now that what I wanted.

how about the ip?
Quote:
Originally Posted by LwdSquashman
echo %computername%
Squashman's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Oct-2004, 09:42 PM #7
Quote:
Originally Posted by kj1983
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.

Code:
for /f "tokens=2* delims=:" %%a in ('ipconfig ^| find "IP Address"') do set ip=%%a
set ip=%ip: =%
kj1983's Avatar
Junior Member with 15 posts.
 
Join Date: Oct 2004
21-Oct-2004, 09:50 PM #8
Quote:
Originally Posted by LwdSquashman
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.

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

It does echo all the ip number.. it echo some weird ip address like
'fp90' that is all
Squashman's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Oct-2004, 09:54 PM #9
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's Avatar
Junior Member with 15 posts.
 
Join Date: Oct 2004
21-Oct-2004, 10:00 PM #10
Quote:
Originally Posted by LwdSquashman
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.

Code:
: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's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Oct-2004, 10:05 PM #11
Let me see the output of ipconfig on your machine.
Squashman's Avatar
Distinguished Member with 12,741 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
21-Oct-2004, 10:40 PM #12
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.

Code:
for /F "tokens=1-6 delims=:. " %%a in ('ipconfig ^| find "IP Address"') do set IPADDRESS=%%c.%%d.%%e.%%f
echo %IPADDRESS%
kj1983's Avatar
Junior Member with 15 posts.
 
Join Date: Oct 2004
22-Oct-2004, 12:02 AM #13
code use:
Code:
: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's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
22-Oct-2004, 11:41 AM #14
@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's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
22-Oct-2004, 11:43 AM #15
I tested with the loop in #12.

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

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:09 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.