Announcement

Collapse
No announcement yet.

batch file statement in logon script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • batch file statement in logon script

    I have a logon script that is mapping a network drive to everyone within an OU. What I need to do is update the batch file with an "if" statement to map a seconde drive to one individual within the OU. Does anyone know the syntax for creating an if statement where if the user logging in is the user in the if statement to mount a second drive?

    THANKS!

  • #2
    Re: batch file statement in logon script

    Moved to scripting forum for better response
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: batch file statement in logon script

      If you want to filter based on group membership, you could use IFMEMBER.EXE

      On the other hand if you want to filter based on username, then do what you have already suggested - use an IF statement. Plenty of sources on Google - have you not looked on there? http://www.google.co.uk/search?q=bat...e+if+statement

      Make use of the %USERNAME% variable. Post back if you run into problems
      Gareth Howells

      BSc (Hons), MBCS, MCP, MCDST, ICCE

      Any advice is given in good faith and without warranty.

      Please give reputation points if somebody has helped you.

      "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

      "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

      Comment


      • #4
        Re: batch file statement in logon script

        Yeah, I'm just not 100% I'm following what I'm finding online, so I thought I would ask here.

        From your post and what I'm reading, should this "IF" statment work if entered into the batch file exactly like this?

        if %username% == appmandan net use y:\\share\e$\data
        (I'm using madeup usernames and file shares)

        Or does it need a FQN?
        Last edited by APPmanDAN; 16th January 2009, 17:18. Reason: clarification

        Comment


        • #5
          Re: batch file statement in logon script

          Code:
          IF %USERNAME% == username goto Next
           
          :Next
          net use ......
          From what i can remember the returned username result is case sensitive, Username is not the same as UserName.

          Rems could probably give a u much better example.
          If the information you receive helps please let us know and leave reputation points where appropriate.

          The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. - Ted Nelson

          Comment


          • #6
            Re: batch file statement in logon script

            thanks for the info

            Comment


            • #7
              Re: batch file statement in logon script

              Originally posted by APPmanDAN View Post
              if %username% == appmandan net use y:\\share\e$\data
              Partly making this suggestion to follow convention more strictly, and partly because the above won't work - you need a space between the drive and the UNC

              2 options - IF, or IF NOT

              Code:
              IF (%USERNAME%) == (appmandan) net use Y: \\server\share
              Code:
              IF NOT (%USERNAME%) == (appmandan) GOTO NEXT
              
              net use Y: \\server\share
              
              :NEXT
              Personally I prefer the second one, they both work the same though.
              Gareth Howells

              BSc (Hons), MBCS, MCP, MCDST, ICCE

              Any advice is given in good faith and without warranty.

              Please give reputation points if somebody has helped you.

              "For by now I could have stretched out my hand and struck you and your people with a plague that would have wiped you off the Earth." (Exodus 9:15) - I could kill you with my thumb.

              "Everything that lives and moves will be food for you." (Genesis 9:3) - For every animal you don't eat, I'm going to eat three.

              Comment


              • #8
                Re: batch file statement in logon script

                Thanks!!!!

                Comment


                • #9
                  Re: batch file statement in logon script

                  Guys,
                  Thanks for all the info. I tested your last post against using my username to mount the drives and it worked. I changed the batch file to the other username and ran it again. The drive did not mount for me that time.

                  Thanks so much for the help!

                  AppmanDAN

                  Comment


                  • #10
                    Re: batch file statement in logon script

                    Thanks for posting back.
                    If the information you receive helps please let us know and leave reputation points where appropriate.

                    The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do. - Ted Nelson

                    Comment


                    • #11
                      Re: batch file statement in logon script

                      Originally posted by g00ner View Post
                      From what i can remember the returned username result is case sensitive, Username is not the same as UserName.
                      .
                      That is true, therefore is better to use the /I switch (Windows NT4/2000/XP).
                      Code:
                      IF /i "%USERNAME%"=="appmandan" Net.exe use Y: "\\server\share" /persistent:no
                      \Rems

                      This posting is provided "AS IS" with no warranties, and confers no rights.

                      __________________

                      ** Remember to give credit where credit's due **
                      and leave Reputation Points for meaningful posts

                      Comment

                      Working...
                      X