|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
%LOGONSERVER% & .bat if then elseI got 3 offices with their own local DC and local file server
One domain I wanted to create one login script for the entire company to map network drives to their local file servers. I know there is a variable %LOGONSERVER% So I am thinking that I need to write an if then else where if the %LOGONSERVER% = corporate then set FILESERVER=Server1 Then my drive mapping would be net use N: \\%FILESERVER%\share Is there any problem in my logic? I don't know how to write the if then else statement.
Show quote
Hide quote
"David Lewis" <u***@microsoft.com> wrote in message I don't know if your logic would work - try it out andnews:c1f341h9u64e7ocmk9m76ld2693o3d06i2@4ax.com... > I got 3 offices with their own local DC and local file server > One domain > I wanted to create one login script for the entire company to map > network drives to their local file servers. > I know there is a variable %LOGONSERVER% > So I am thinking that I need to write an if then else where > if the %LOGONSERVER% = corporate then set FILESERVER=Server1 > > Then my drive mapping would be > net use N: \\%FILESERVER%\share > > Is there any problem in my logic? > I don't know how to write the if then else statement. see what happens! Here is the syntax: @echo off if /i "%LogonServer"%=="Corporate" (set FileServer=Server1) else (set FileServer=Server2) net use . . . Pegasus (MVP) wrote:
> "%LogonServer%" :)> @echo off > if /i "%LogonServer"%=="Corporate" (set FileServer=Server1) else (set "George Woodbine" <geo***@woodbine.com> wrote in message Oops . . . thanks for pointing out this silly error!news:4241fa01$0$2763$cc9e4d1f@news-text.dial.pipex.com... > Pegasus (MVP) wrote: > > > > @echo off > > if /i "%LogonServer"%=="Corporate" (set FileServer=Server1) else (set > > "%LogonServer%" :) ya I couldn't figure out why the code was not working :)
George Woodbine <geo***@woodbine.com> Show quoteHide quote |>Pegasus (MVP) wrote: |>> |>> @echo off |>> if /i "%LogonServer"%=="Corporate" (set FileServer=Server1) else (set |> |>"%LogonServer%" :) thankx, that did the trick
I just had to tweak your code a little This way I was able to instead of having 4 login scripts, now I have one if /i "%LOGONSERVER%"=="\\Corp" (set FileServer=\\Corp-Files) if /i "%LOGONSERVER%"=="\\Remote" (set FileServer=\\Remote) net use e: /delete net use e: %FileServer%\CAD /PERSISTENT:YES net use f: /delete net use f: %FileServer%\Docs /PERSISTENT:YES net use u: /delete net use u: %FileServer%\Users\%USERNAME% /PERSISTENT:YES My situation is that in my corporate office, there is a separate DC and file server but my remote offices have one server for both DC and files Now I just need to figure out how to add mapped drives bassed on security groups. How can I do that? Show quoteHide quote "Pegasus \(MVP\)" <I.***@fly.com> |> |>"David Lewis" <u***@microsoft.com> wrote in message |>news:c1f341h9u64e7ocmk9m76ld2693o3d06i2@4ax.com... |>> I got 3 offices with their own local DC and local file server |>> One domain |>> I wanted to create one login script for the entire company to map |>> network drives to their local file servers. |>> I know there is a variable %LOGONSERVER% |>> So I am thinking that I need to write an if then else where |>> if the %LOGONSERVER% = corporate then set FILESERVER=Server1 |>> |>> Then my drive mapping would be |>> net use N: \\%FILESERVER%\share |>> |>> Is there any problem in my logic? |>> I don't know how to write the if then else statement. |> |>I don't know if your logic would work - try it out and |>see what happens! Here is the syntax: |> |>@echo off |>if /i "%LogonServer"%=="Corporate" (set FileServer=Server1) else (set |>FileServer=Server2) |>net use . . . |> "David Lewis" <u***@microsoft.com> wrote in message <snipped>news:6a4441pa98tbmb4472a9u49n8e6fkcmm6u@4ax.com... >Now I just need to figure out how to add mapped drives based on security Look into ifmember.exe>groups. How can I do that? -- Todd J Heron, MCSE Windows Server 2003/2000/NT; CCA ---------------------------------------------------------------------------- This posting is provided "as is" with no warranties and confers no rights. thankx so how would I write a batch to
ifmember "Domain Admins" then net use ....... Show quoteHide quote "Todd J Heron" <todd_heron_no_spam@hotmail.com> |>ifmember.exe "David Lewis" <u***@microsoft.com> wrote in message Below adds the user's group membership needed for selective processing to a news:mv84411p14ideh3fjomiiuahm2ktv0kogv@4ax.com... >thankx so how would I write a batch to ifmember "Domain Admins" then net >use ....... small text file in the user's profile folder, then the second command parses the text file (named Info.txt) for specific group name (a global group) and maps a drive letter h: to the network share. Error checking in line 3 dumps out the loginscript if the groupname you are looking for doesn't match and line 4 simply deletes any existing maps to h: in case the network share has changed locations etc... ifmember /v /l >> "%USERPROFILE%\Info.txt" type "%USERPROFILE%\Info.txt" |find "<domainname>\<groupname>" /i if errorlevel 1 goto :ENDif exist h:\ net use h: /d /y net use h: \\<UNCpathtoShareName> :END -- Todd J Heron, MCSE Windows Server 2003/2000/NT; CCA ---------------------------------------------------------------------------- This posting is provided "as is" with no warranties and confers no rights.
Show quote
Hide quote
"Todd J Heron" <todd_heron_no_spam@hotmail.com> wrote in message You could also do it like this:news:eet2Z7BMFHA.1172@TK2MSFTNGP12.phx.gbl... > "David Lewis" <u***@microsoft.com> wrote in message > news:mv84411p14ideh3fjomiiuahm2ktv0kogv@4ax.com... > >thankx so how would I write a batch to ifmember "Domain Admins" then net > >use ....... > > Below adds the user's group membership needed for selective processing to a > small text file in the user's profile folder, then the second command parses > the text file (named Info.txt) for specific group name (a global group) and > maps a drive letter h: to the network share. Error checking in line 3 dumps > out the loginscript if the groupname you are looking for doesn't match and > line 4 simply deletes any existing maps to h: in case the network share has > changed locations etc... > > ifmember /v /l >> "%USERPROFILE%\Info.txt" > type "%USERPROFILE%\Info.txt" |find "<domainname>\<groupname>" /i > if errorlevel 1 goto :END > if exist h:\ net use h: /d /y > net use h: \\<UNCpathtoShareName> > > :END > > -- > Todd J Heron, MCSE > Windows Server 2003/2000/NT; CCA > -------------------------------------------------------------------------- -- > This posting is provided "as is" with no warranties and confers no rights. > ifmember "Group 1" || net use \\YourServer\Share1 ifmember "Group 2" || net use \\YourServer\Share2 Type ifmember /? at the Command Prompt to see what switches you should use. works, thankx
Show quoteHide quote "Pegasus \(MVP\)" <I.***@fly.com> |> |>"Todd J Heron" <todd_heron_no_spam@hotmail.com> wrote in message |>news:eet2Z7BMFHA.1172@TK2MSFTNGP12.phx.gbl... |>> "David Lewis" <u***@microsoft.com> wrote in message |>> news:mv84411p14ideh3fjomiiuahm2ktv0kogv@4ax.com... |>> >thankx so how would I write a batch to ifmember "Domain Admins" then net |>> >use ....... |>> |>> Below adds the user's group membership needed for selective processing to |>a |>> small text file in the user's profile folder, then the second command |>parses |>> the text file (named Info.txt) for specific group name (a global group) |>and |>> maps a drive letter h: to the network share. Error checking in line 3 |>dumps |>> out the loginscript if the groupname you are looking for doesn't match and |>> line 4 simply deletes any existing maps to h: in case the network share |>has |>> changed locations etc... |>> |>> ifmember /v /l >> "%USERPROFILE%\Info.txt" |>> type "%USERPROFILE%\Info.txt" |find "<domainname>\<groupname>" /i |>> if errorlevel 1 goto :END |>> if exist h:\ net use h: /d /y |>> net use h: \\<UNCpathtoShareName> |>> |>> :END |>> |>> -- |>> Todd J Heron, MCSE |>> Windows Server 2003/2000/NT; CCA |>> -------------------------------------------------------------------------- remember..
%logonserver% is only valid on 2000 and XP, 9x clients don't respect it.. Diane Show quoteHide quote "David Lewis" <u***@microsoft.com> wrote in message news:29a641hpq4e0kgt44obte1jd7opilv24dq@4ax.com... > works, thankx > > "Pegasus \(MVP\)" <I.***@fly.com> > |> > |>"Todd J Heron" <todd_heron_no_spam@hotmail.com> wrote in message > |>news:eet2Z7BMFHA.1172@TK2MSFTNGP12.phx.gbl... > |>> "David Lewis" <u***@microsoft.com> wrote in message > |>> news:mv84411p14ideh3fjomiiuahm2ktv0kogv@4ax.com... > |>> >thankx so how would I write a batch to ifmember "Domain Admins" then > net > |>> >use ....... > |>> > |>> Below adds the user's group membership needed for selective processing > to > |>a > |>> small text file in the user's profile folder, then the second command > |>parses > |>> the text file (named Info.txt) for specific group name (a global > group) > |>and > |>> maps a drive letter h: to the network share. Error checking in line 3 > |>dumps > |>> out the loginscript if the groupname you are looking for doesn't match > and > |>> line 4 simply deletes any existing maps to h: in case the network > share > |>has > |>> changed locations etc... > |>> > |>> ifmember /v /l >> "%USERPROFILE%\Info.txt" > |>> type "%USERPROFILE%\Info.txt" |find "<domainname>\<groupname>" /i > |>> if errorlevel 1 goto :END > |>> if exist h:\ net use h: /d /y > |>> net use h: \\<UNCpathtoShareName> > |>> > |>> :END > |>> > |>> -- > |>> Todd J Heron, MCSE > |>> Windows Server 2003/2000/NT; CCA > |>> -------------------------------------------------------------------------- > thankx. We don't support 9x :) thank god
Show quoteHide quote "Diane McCorkle" <diane.mccorkle at atcassociates.com> |>remember.. |>%logonserver% is only valid on 2000 and XP, 9x clients don't respect it.. |> |>Diane |> |> |>"David Lewis" <u***@microsoft.com> wrote in message |>news:29a641hpq4e0kgt44obte1jd7opilv24dq@4ax.com... |>> works, thankx |>> |>> "Pegasus \(MVP\)" <I.***@fly.com> |>> |> |>> |>"Todd J Heron" <todd_heron_no_spam@hotmail.com> wrote in message |>> |>news:eet2Z7BMFHA.1172@TK2MSFTNGP12.phx.gbl... |>> |>> "David Lewis" <u***@microsoft.com> wrote in message |>> |>> news:mv84411p14ideh3fjomiiuahm2ktv0kogv@4ax.com... |>> |>> >thankx so how would I write a batch to ifmember "Domain Admins" then |>> net |>> |>> >use ....... |>> |>> |>> |>> Below adds the user's group membership needed for selective processing |>> to |>> |>a |>> |>> small text file in the user's profile folder, then the second command |>> |>parses |>> |>> the text file (named Info.txt) for specific group name (a global |>> group) |>> |>and |>> |>> maps a drive letter h: to the network share. Error checking in line 3 |>> |>dumps |>> |>> out the loginscript if the groupname you are looking for doesn't match |>> and |>> |>> line 4 simply deletes any existing maps to h: in case the network |>> share |>> |>has |>> |>> changed locations etc... |>> |>> |>> |>> ifmember /v /l >> "%USERPROFILE%\Info.txt" |>> |>> type "%USERPROFILE%\Info.txt" |find "<domainname>\<groupname>" /i |>> |>> if errorlevel 1 goto :END |>> |>> if exist h:\ net use h: /d /y |>> |>> net use h: \\<UNCpathtoShareName> |>> |>> |>> |>> :END |>> |>> |>> |>> -- |>> |>> Todd J Heron, MCSE |>> |>> Windows Server 2003/2000/NT; CCA |>> |>> -------------------------------------------------------------------------- |>> |>
Other interesting topics
QuickBooks and its users
Mapped Drives and Home Folders Windows 2003 image problem in boot XP after using Linux ADPREP Failed for upgrading to Windows 2003 Invalid Domain Controller Certificate NT 4.0 and 2003 Trust DNS errors after moving Windows 2003 server to DMZ apply permission to child objects NTBackup and/or Scheduled Task Not Working |
|||||||||||||||||||||||