Close

Results 1 to 10 of 10
  1. #1
    DF Rookie JJUK's Avatar
    Join Date
    Oct 2013
    Location
    UK
    Posts
    22
    Thanks
    6
    Thanked:        1
    Karma Level
    0

    Default Map Network Drive Script

    Good afternoon,

    I wonder if anyone can point me into the right direction, or help me out. I'm looking for some kind of script to Map a Network Drive and Un-map a network drive. It's not for a large company or anything. It's just for a couple of friends to connect to. The easier way to do this, I thought was through vbs or bat files. However my programming skills is very slim.

    So basically,

    Login.VBS or .BAT
    I want the user to double click a file. It then requests the user to enter their Username / Password. If successful > It maps the network drive.

    Logout.VBS or .BAT
    Straight forward, really. The user double clicks on the file and it logs them out of the Mapped Network Drive.

  2. #2
    DF Super Moderator
    DejaVu's Avatar
    Join Date
    Nov 2005
    Location
    Essex
    Posts
    9,107
    Thanks
    1,836
    Thanked:        4,004
    Karma Level
    953

    Default Re: Map Network Drive Script

    Easy -

    Inside AddNetworkDrive.bat -

    Code:
    net use S: \\myipaddress\andtherest\ofmyshare\name\here
    
    Inside RemoveNetworkDrive.bat -

    Code:
    net use s: /delete
    

    2 Thanks given to DejaVu

    JJUK (20th February 2014),  macmilm (20th February 2014)  


  3. #3
    DF VIP Member Basset's Avatar
    Join Date
    Sep 2013
    Location
    Lancashire
    Posts
    188
    Thanks
    61
    Thanked:        81
    Karma Level
    139

    Default Re: Map Network Drive Script

    If you want to ask for the username and password you could do the following

    @echo off
    echo Enter Username and Password to map drive
    set /p user=Enter UserId:
    set /p pass=Enter Password:
    net use S: \\computer\sharename %pass% /user:%user%

    Thanks to Basset

    JJUK (20th February 2014)  


  4. #4
    DF Rookie JJUK's Avatar
    Join Date
    Oct 2013
    Location
    UK
    Posts
    22
    Thanks
    6
    Thanked:        1
    Karma Level
    0

    Default

    Ah perfect. This will come in very handy. Many thans

    Ah perfect. This will come in very handy. Many thanks to the both of you.

    Ah perfect. This will come in very handy. Many thanks to the both of you.



    third time lucky matey
    Last edited by Mickey; 20th February 2014 at 09:24 PM.

  5. #5
    DF General DogsBody
    Mickey's Avatar
    Join Date
    Nov 2006
    Location
    Digital Forums
    Posts
    16,955
    Thanks
    1,879
    Thanked:        2,077
    Karma Level
    1253

    Default Re: Map Network Drive Script

    Thought id put them all together for you matey

    Thanks to Mickey

    JJUK (21st February 2014)  


  6. #6
    DF Rookie JJUK's Avatar
    Join Date
    Oct 2013
    Location
    UK
    Posts
    22
    Thanks
    6
    Thanked:        1
    Karma Level
    0

    Default Re: Map Network Drive Script

    Cheers, appreciate it.

    Sorry, My laptop froze and I didn't know if the message had sent. I must have clicked a number of times. Oops.

  7. #7
    DF VIP Member Over Carl's Avatar
    Join Date
    Apr 2006
    Location
    London
    Posts
    13,125
    Thanks
    3,975
    Thanked:        1,690
    Karma Level
    1251

    Default Re: Map Network Drive Script

    You may want to create a shortcut running the batch file minimised, otherwise the credentials will be displayed to everyone when logging on. Then next you may want to consider that the batch file also contains the password in plaintext.

  8. #8
    DF VIP Member keyser666's Avatar
    Join Date
    Sep 2013
    Location
    United Kingdom
    Posts
    275
    Thanks
    92
    Thanked:        152
    Karma Level
    156

    Default Re: Map Network Drive Script

    Quote Originally Posted by Basset View Post
    If you want to ask for the username and password you could do the following

    @echo off
    echo Enter Username and Password to map drive
    set /p user=Enter UserId:
    set /p pass=Enter Password:
    net use S: \\computer\sharename %pass% /user:%user%
    Think the original response is better as they will be asked to authenticate anyway (assuming they dont have a local account on the target machine with the same password)and therefore no password would be contained within the batch file

  9. #9
    DF VIP Member Mr.James's Avatar
    Join Date
    Nov 2000
    Location
    town
    Posts
    4,264
    Thanks
    233
    Thanked:        408
    Karma Level
    575

    Default Re: Map Network Drive Script

    Just for completion, here's the vbs way. This shouldn't give any pop-up windows (unless there's a problem).

    AddNetworkDrive.vbs:
    Code:
    Dim WSHNetwork
    Set WSHNetwork = CreateObject("WScript.Network")
    WSHNetwork.MapNetworkDrive "Z:", "\\<PCName>\<ShareName>", "True" , "<LoginName>" , "<Password>"
    You don't need the , "<LoginName>" , "<Password>" bit if you have matching user accounts on the 'server' PC. But it comes in handy if you want everyone to authenticate as a generic user/password

    RemoveNetworkDrive.vbs:
    Code:
    Dim WSHNetwork
    Set WSHNetwork = CreateObject("WScript.Network")
    WSHNetwork.RemoveNetworkDrive ("Z:"), True, True

    2 Thanks given to Mr.James

    JJUK (9th March 2014),  keyser666 (24th February 2014)  


  10. #10
    DF Rookie JJUK's Avatar
    Join Date
    Oct 2013
    Location
    UK
    Posts
    22
    Thanks
    6
    Thanked:        1
    Karma Level
    0

    Default Re: Map Network Drive Script

    Hi,

    Thank you very much for that. These will come in very useful.

Similar Threads

  1. What cars do you drive ?
    By clayton in forum Cars & Motorbikes
    Replies: 625
    Last Post: 18th March 2010, 09:12 AM
  2. If your xbox dvd drive is dead... read in ;)
    By maltloaf in forum Microsoft Consoles
    Replies: 3
    Last Post: 26th December 2002, 12:33 PM
  3. Replies: 18
    Last Post: 12th October 2002, 01:59 PM
  4. Buggered drive permanently by tweaking pot?
    By oka97 in forum Microsoft Consoles
    Replies: 10
    Last Post: 9th October 2002, 05:36 PM
  5. XBOX DVD drive fails to eject
    By treepid in forum Microsoft Consoles
    Replies: 1
    Last Post: 13th September 2002, 04:35 PM

Social Networking Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •