Home / Microsoft / Microsoft DOS / Assigning value to a variable
0 Members and 3 Guests are viewing this topic. « previous next »
Pages: 1 [2]  All - (Bottom) Print
Author Topic: Assigning value to a variable  (Read 1265 times)
Sidewinder
Guru



Thanked: 97
Posts: 4,341

Experience: Familiar
OS: Windows 7

« Reply #15 on: November 24, 2005, 03:59:31 PM »

Actually you should see it's value since your batch file does not turn echo off. However, this will work:

Code: [Select]

for /f "tokens=1-6 delims=:. " %%i in ('ipconfig ^| find /i "ip address"') do set ip=%%k.%%l.%%m.%%n
echo %ip%


When debugging batch files (scripts too!) echo is a very handy instruction to have around.

Hope this helps.  8)
IP logged

If you don't know where you are going, any road will get you there

                                                                            -Lewis Carroll
Blink
Topic Starter
Intermediate



Posts: 135



It just sounds to me like you need to unplug, man.

« Reply #16 on: November 24, 2005, 04:08:09 PM »

It correctly displayed my ip address. So if the code is logically correct and the variable is correctly set to the ip of my machine, why is it that only the first part of the if statement works? if the ip address is outside the range specified and applies to the else command, the default printer does not change.
IP logged

Blink
Topic Starter
Intermediate



Posts: 135



It just sounds to me like you need to unplug, man.

« Reply #17 on: November 24, 2005, 04:19:39 PM »

i think i have solved the problem, i forgot that my computer has 2 network cards and this could be where the problem is coming from. i tried it on another computer on the network and it seemed to work perfectly. thanks a lot for your help sidewinder.
IP logged

Sidewinder
Guru



Thanked: 97
Posts: 4,341

Experience: Familiar
OS: Windows 7

« Reply #18 on: November 24, 2005, 04:33:20 PM »

You're very welcome. So now stick around, your knowledge may help someone else out.

8)
IP logged

If you don't know where you are going, any road will get you there

                                                                            -Lewis Carroll
Pages: 1 [2]  All - (Top) Print 
Home / Microsoft / Microsoft DOS / Assigning value to a variable « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.099 seconds with 19 queries.