Please Read: Significant Update Planned, Migrating Forum Software This Month

See more
See less

Batch file issue

  • Filter
  • Time
  • Show
Clear All
new posts

  • Batch file issue

    Hi All

    We are having an issue with mapping drives in group policy on windows 7 machines.

    The batch file has a number of drives to map but not all drives will map due to permissions. If the batch file gets to 1 where the users does not have permissions, instead of bypassing that drive it then never seems to complete and any further drives don't get mapped.

    If I run the file manually it asked for user name for the failed mapping then never goes any further.

    How do I get the script to continue if the user does not have permissions

    eg mapping

    net use H: "\\SRV1\terms & conditions"
    net use V: "\\VISUALFILES\sos"
    net use P: "\\SRV1\probate"
    net use O: "\\srv1\Legal Forms"

    Any help here would be great, thanks


  • #2
    Re: Batch file issue

    Mod edit: Moved thread to scripting forums

    When the user does not have permissins to map the drive, they are asked to enter an alternate username and password. That is where your logon batch hangs, waiting for user input.

    If the user is running the batch manually he or she can hit the enter key to continue, leaving the alternate user name field empty.

    In a batch you can program an Enter keystroke as answer like this:

    echo.| net use H: "\\SRV1\terms & conditions"
    echo.| net.exe use V: "\\VISUALFILES\sos"
    echo.| net.exe use P: "\\SRV1\probate"
    echo.| net.exe use O: "\\srv1\Legal Forms"

    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


    • #3
      Re: Batch file issue

      Another way to resolve the hang is not to encounter it. We map drives for users based on membership in particular groups. If they're not a member of a group, that drive letter doesn't get mapped to that user during logon. If the groups are given the permissions on the shares as well, then the only variable is who belongs to the group.

      For each drive map, create a group. Assign that group to the share and set your NTFS permissions. Then create a GPO for the mapped drive letter to the share, and set security filtering to include Domain Admins (just in case) and the group you created earlier. Then add members to the group and have those users log on. They see that drive, no one else does.
      MSCA (2003/XP), Security+, CCNA

      ** Remember: credit where credit is due, and reputation points as appropriate **


      • #4
        Re: Batch file issue

        And since it is Win7, there is a good chance you can use Group Policy Preferences with Client Side Targetting to only map the drive if the user is in the group - no scripts required
        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

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


        • #5
          Re: Batch file issue

          hanks All

          I have gone for the echo.| as I don't understand how I would do groups