twig123 Posted November 10, 2008 Share Posted November 10, 2008 (edited) Hey all,First of all, you guys are my lifeline and I want to thank you for all of your help in the past!I am trying to map a network drive, depending on what domain they are on...I can't figure out how to get the dual variable to work properly, here is what I have:set D_Domain1=Server1set D_Domain2=Server2set D_Domain3=Server3set Server=%D_%USERDNSDOMAIN%%net use O: \\%Server%\ShareI know that the %'s are wrong and is what is causing my problem... but I don't know how to fix it.%USERDNSDOMAIN% is the user's full domain name and I want to set %Server% as D_InsertUsersDomainHere but the Double %%'s are tripping me up.Any Ideas? Edited November 10, 2008 by twig123 Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted November 11, 2008 Share Posted November 11, 2008 There may be other ways to solve this, but this was my first thought:set D_Domain1=Server1set D_Domain2=Server2set D_Domain3=Server3for /f "tokens=1,* delims==" %%a in ('set D_^|find /i "%USERDNSDOMAIN%"') do set Server=%%bnet use O: \\%Server%\Share Link to comment Share on other sites More sharing options...
jaclaz Posted November 11, 2008 Share Posted November 11, 2008 If only I could understand what you are trying to do.......Where is USERDNSDOMAIN defined?However maybe this is the missing point, (alternate solution to the one already posted) enabling delayed expansion of variables and use the !var! syntax together with the %var% one, that allows for !var1_%var2%!SETLOCAL ENABLEDELAYEDEXPANSIONSET USERDNSDOMAIN=Domain2set D_Domain1=Server1set D_Domain2=Server2set D_Domain3=Server3set Server=!D_%USERDNSDOMAIN%!SET ServerPAUSEnet use O: \\%Server%\Sharejaclaz Link to comment Share on other sites More sharing options...
twig123 Posted November 12, 2008 Author Share Posted November 12, 2008 %USERDNSDOMAIN% is a system wide variable that is set by windows if a computer is joined to a Domain.I was trying to make a new variable out of 2 existing variables to grab the data that was contained within the 3rd variable. Both of your replies seem to accomplish this goal in different ways.Thanks 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