+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 25
Scripts Thread, Script to Map Home Directory after prompting for username in Coding and Web Development; hi there i have a group of users that use laptops and are not part of a domain. they all ...
  1. #1
    tri_94's Avatar
    Join Date
    Feb 2007
    Location
    Lincolnshire
    Posts
    117
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    17

    Script to Map Home Directory after prompting for username

    hi there i have a group of users that use laptops and are not part of a domain. they all have usernames on the domain. and what i need to be able to map there mydocs folder from the server but the script ideally needs to prompt for a username and then use that in the mapping....


    example

    net use T: "\\Server\*there username*$

    to map the hidden share.


    in a perfect world i would also like the script to be able to connect to 2 other network shares and a printer too.

    any ideas
    thanks
    nick

  2. #2

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,039
    Thank Post
    852
    Thanked 2,666 Times in 2,263 Posts
    Blog Entries
    9
    Rep Power
    767
    Ask @SimpleSi this kind of setup is his speciality

  3. #3

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Code:
    strInput = InputBox( "Enter your name now!!!", "DriveMapping")
    
    dim oShell
    Set oShell = CreateObject("WScript.Shell")
    oShell.Run "NET USE X: \\server\" & strInput & "$"
    (Not tested, but should do it)

    But aren't you going to need username/passwords etc to connect to the domain, or is it open?

    Steve

  4. #4
    tri_94's Avatar
    Join Date
    Feb 2007
    Location
    Lincolnshire
    Posts
    117
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    17
    Yes i am going to need a username and password to connect to the server. so is there a way of adding that in the code? i can setup a user with access to all home folders.

  5. #5
    tri_94's Avatar
    Join Date
    Feb 2007
    Location
    Lincolnshire
    Posts
    117
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    17
    just tried that script and it working if i have connected to the server with a username and password. but another question i have two server and have different users on each is there any way of saying if that share is not on server1 look at server 2 if that makes any sense?

    but thanks alot for the script

  6. #6
    waldronm2000's Avatar
    Join Date
    Dec 2009
    Location
    Southend
    Posts
    129
    Thank Post
    49
    Thanked 12 Times in 11 Posts
    Rep Power
    12
    Haven't tested this, but if you were to add & "/user:domainname\" & strInput to the end of the last line, (replace domainname with your domain of course), that should then ask for the password when it shells out to map the drive.

  7. #7

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by tri_94 View Post
    Yes i am going to need a username and password to connect to the server. so is there a way of adding that in the code? i can setup a user with access to all home folders.
    Should be able to just add
    Code:
    /user:domain\username password
    on end of code like this:

    Code:
    strInput = InputBox( "Enter your name now!!!", "DriveMapping")
    
    dim oShell
    Set oShell = CreateObject("WScript.Shell")
    oShell.Run "NET USE X: \\server\" & strInput & "$ /user:domain\username password"
    Not tested though,
    Steve

  8. #8
    tri_94's Avatar
    Join Date
    Feb 2007
    Location
    Lincolnshire
    Posts
    117
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    17
    i must be doing somthing wrong as its not working for me

  9. #9

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    What bit? Any errors?

    Steve

  10. #10
    tri_94's Avatar
    Join Date
    Feb 2007
    Location
    Lincolnshire
    Posts
    117
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    17
    nope not errors the script works without the "$ /user:domain\username password"

    am i right in thinking it would be /user:mydomain\myusername mypassword"

  11. #11

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,039
    Thank Post
    852
    Thanked 2,666 Times in 2,263 Posts
    Blog Entries
    9
    Rep Power
    767
    Quote Originally Posted by tri_94 View Post
    nope not errors the script works without the "$ /user:domain\username password"

    am i right in thinking it would be /user:mydomain\myusername mypassword"
    Yes, you can grab the command line parameters by using "net use /?"

  12. #12

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by tri_94 View Post
    nope not errors the script works without the "$ /user:domain\username password"

    am i right in thinking it would be /user:mydomain\myusername mypassword"
    Aye

    Code:
    strInput = InputBox( "Enter your name now!!!", "DriveMapping")
    
    dim oShell
    Set oShell = CreateObject("WScript.Shell")
    oShell.Run "NET USE Y: \\server\" & strInput & "$ /user:MyDomain\BestUserEver EpicPassword"
    Works, just tried it on mine

    Steve

  13. #13
    tri_94's Avatar
    Join Date
    Feb 2007
    Location
    Lincolnshire
    Posts
    117
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    17
    right i've got that working. it was because my test machine was on the domain and therefore had the authenitcation.

    so is it possible to have it look at two servers and a way of telling it if that share is not on server1 look at server 2 if that makes any sense?

  14. #14
    waldronm2000's Avatar
    Join Date
    Dec 2009
    Location
    Southend
    Posts
    129
    Thank Post
    49
    Thanked 12 Times in 11 Posts
    Rep Power
    12
    Maybe instead of shelling out to a one-line net use command, shell to a three-line .cmd file that picks up the username, password and sharename as parameters, tries to use them to map to the share on server1, exits if errorlevel is 0, otherwise maps to server2...

  15. #15
    tri_94's Avatar
    Join Date
    Feb 2007
    Location
    Lincolnshire
    Posts
    117
    Thank Post
    2
    Thanked 2 Times in 2 Posts
    Rep Power
    17
    right and how could i do that?

    so is it not possible to use the script that "steve21" gave me and add something to it?

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 6
    Last Post: 23rd August 2012, 09:40 PM
  2. Giving user access to all home directories
    By paularmstrong in forum Windows
    Replies: 11
    Last Post: 7th November 2007, 08:27 AM
  3. Replies: 0
    Last Post: 20th August 2007, 02:20 PM
  4. Script to set active directory object security
    By meastaugh1 in forum Windows
    Replies: 4
    Last Post: 5th January 2007, 04:28 AM
  5. Replies: 19
    Last Post: 20th June 2006, 03:53 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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