Jump to content

Recommended Posts

Posted (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=Server1
set D_Domain2=Server2
set D_Domain3=Server3
set Server=%D_%USERDNSDOMAIN%%
net use O: \\%Server%\Share

I 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 by twig123

Posted

There may be other ways to solve this, but this was my first thought:


set D_Domain1=Server1
set D_Domain2=Server2
set D_Domain3=Server3

for /f "tokens=1,* delims==" %%a in ('set D_^|find /i "%USERDNSDOMAIN%"') do set Server=%%b
net use O: \\%Server%\Share

Posted

If only I could understand what you are trying to do....

...Where is USERDNSDOMAIN defined?

:w00t:

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 ENABLEDELAYEDEXPANSION

SET USERDNSDOMAIN=Domain2

set D_Domain1=Server1
set D_Domain2=Server2
set D_Domain3=Server3
set Server=!D_%USERDNSDOMAIN%!

SET Server
PAUSE
net use O: \\%Server%\Share

jaclaz

Posted

%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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...