jjvs Posted July 26, 2010 Share Posted July 26, 2010 (edited) Just a little thought.Wouldn't it be easier to skip the whole "delims" thing and use:FOR /F "TOKENS=15" %%A IN ('IPCONFIG /ALL^|FIND "DHCP Server"') DO @SET DHCPSERVER=%%Aor if you insist in using delims use this:FOR /F "TOKENS=2,* DELIMS=:. " %%A IN ('IPCONFIG /ALL ^| FIND "DHCP Server"') DO @SET DHCPSERVER=%%BBTW: Delims doesn't treat an uppercase and lowercase character the same way. Edited July 26, 2010 by jjvs Link to comment Share on other sites More sharing options...
Yzöwl Posted July 26, 2010 Share Posted July 26, 2010 Just a little thought.Wouldn't it be easier to skip the whole "delims" thing and use:FOR /F "TOKENS=15" %%A IN ('IPCONFIG /ALL^|FIND "DHCP Server"') DO @SET DHCPSERVER=%%AYes you could also forget the counting too!FOR /F "TOKENS=*" %%# IN ('IPCONFIG /ALL^|FIND "DHCP Server"') DO SET "DHCPSERVER=%%#" & CALL SET "DHCPSERVER=%%DHCPSERVER:*: =%%" Link to comment Share on other sites More sharing options...
patronu Posted July 26, 2010 Author Share Posted July 26, 2010 the last part doesn't seem to work. I get that DHCPSERVER equals with %DHCPSERVER:*: =%CALL SET "DHCPSERVER=%%DHCPSERVER:*: =%%" Link to comment Share on other sites More sharing options...
Yzöwl Posted July 26, 2010 Share Posted July 26, 2010 the last part doesn't seem to work. I get that DHCPSERVER equals with %DHCPSERVER:*: =%CALL SET "DHCPSERVER=%%DHCPSERVER:*: =%%"It works fine on all of my operating systems!Try the following exactly as is, (as a verification check):@ECHO OFF & SETLOCAL ENABLEEXTENSIONSFOR /F "TOKENS=*" %%# IN ('IPCONFIG /ALL^|FIND "DHCP Server"') DO ( SET "DHCPSERVER=%%#" & CALL SET "DHCPSERVER=%%DHCPSERVER:*: =%%")ECHO=[%DHCPSERVER%]PING -n 6 127.0.0.1 1>NUL Link to comment Share on other sites More sharing options...
patronu Posted July 26, 2010 Author Share Posted July 26, 2010 it works now. thank you. Link to comment Share on other sites More sharing options...
jaclaz Posted July 27, 2010 Share Posted July 27, 2010 Yes you could also forget the counting too!FOR /F "TOKENS=*" %%# IN ('IPCONFIG /ALL^|FIND "DHCP Server"') DO SET "DHCPSERVER=%%#" & CALL SET "DHCPSERVER=%%DHCPSERVER:*: =%%"Also:SETLOCAL ENABLEDELAYEDEXPANSIONFOR /F "TOKENS=2 DELIMS=:" %%# IN ('IPCONFIG /ALL^|FIND "DHCP Server"') DO SET DHCPSERVER=%%#&SET DHCPSERVER=!DHCPSERVER:~1!But we are using the & jaclaz Link to comment Share on other sites More sharing options...
Yzöwl Posted July 27, 2010 Share Posted July 27, 2010 But we are using the & Correct, but as I intimated earlier, keeping to a short/single command is not necessarily better/faster! Link to comment Share on other sites More sharing options...
jaclaz Posted July 27, 2010 Share Posted July 27, 2010 Yep, personally I find the "main"+"sub-routines calls" or "functions" a much better, clearer way to write batches.@patronuHere is a nice source, just in case:http://www.dostips.com/http://www.dostips.com/DtTutoFunctions.phpjaclaz Link to comment Share on other sites More sharing options...
patronu Posted July 27, 2010 Author Share Posted July 27, 2010 thank you jaclaz for the guides. I'll read them tomorrow. Right now I have another problem. Stupid comma or something Tomorrow I'll read those guides and if I can't find a solution I'll post here Link to comment Share on other sites More sharing options...
patronu Posted July 28, 2010 Author Share Posted July 28, 2010 didnt' found a solution for the other problem. start "%temp%\rd\1\update\update.exe" /q /n /zthis is the command. I get invalid switch - "/q"if I run this command from a path that contains no spaces there is no problem. but I wanted to run it from temporary folder so I have to use quotes but doing so it won't recognize the parameters. so how to use those switches when I have quotes? Link to comment Share on other sites More sharing options...
jaclaz Posted July 28, 2010 Share Posted July 28, 2010 didnt' found a solution for the other problem. start "%temp%\rd\1\update\update.exe" /q /n /zthis is the command. I get invalid switch - "/q"if I run this command from a path that contains no spaces there is no problem. but I wanted to run it from temporary folder so I have to use quotes but doing so it won't recognize the parameters. so how to use those switches when I have quotes?Try putting a TITLE to it:http://ss64.com/nt/start.htmlTry putting the parameters inside the quotes, i.e.:start "MyWindow" /WAIT "%temp%\rd\1\update\update.exe /q /n /z"jaclaz Link to comment Share on other sites More sharing options...
Yzöwl Posted July 28, 2010 Share Posted July 28, 2010 It doesn't even require a title, (just the quotes for one):START "" /wait "%TEMP%\RD\UPDATE\UPDATE.EXE" /q /n /zIn fact it's very likely that you dont even need to use start at all!"%TEMP%\RD\UPDATE\UPDATE.EXE" /q /n /z Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now