November 10, 200817 yr 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, 200817 yr by twig123
November 11, 200817 yr 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
November 11, 200817 yr 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
November 12, 200817 yr Author %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
Create an account or sign in to comment