none
Batch file for net use to promt for ID as well as password RRS feed

  • Question

  • I've done lots of batch files in the past and I'm familiar with net use but in the past I've always supplied the user ID in the batch file and prompted for just the password.

    But I now have a situation where I need to prompt for the user ID as well as the password and I don't see any way to do that with net use.

    Does anyone else know of a way to do that or know of some other script I can use to map a drive which asks for user ID and password?


    Jonathan

    Thursday, March 6, 2014 5:43 PM

Answers

  • You can prompt for a username using set /p, and net use can prompt for the password. Example:


    @echo off
    setlocal enableextensions
    set /p "_USERNAME=Enter user name: "
    net use X: "\\server\sharename" /user:"%_USERNAME%" *
    endlocal
    


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by SmallBizAdmin Thursday, March 6, 2014 6:10 PM
    Thursday, March 6, 2014 5:48 PM
    Moderator

All replies

  • You can prompt for a username using set /p, and net use can prompt for the password. Example:


    @echo off
    setlocal enableextensions
    set /p "_USERNAME=Enter user name: "
    net use X: "\\server\sharename" /user:"%_USERNAME%" *
    endlocal
    


    -- Bill Stewart [Bill_Stewart]

    • Marked as answer by SmallBizAdmin Thursday, March 6, 2014 6:10 PM
    Thursday, March 6, 2014 5:48 PM
    Moderator
  • Great! That is exactly what I was looking for. Thanks!


    Jonathan

    Thursday, March 6, 2014 6:10 PM