+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 28
Scripts Thread, Mapping drives from non domain pcs via scripts in Coding and Web Development; Does anybody have a script (or know an app that will do it) that will prompt for a username and ...
  1. #1

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,817
    Thank Post
    272
    Thanked 1,138 Times in 1,034 Posts
    Rep Power
    350

    Mapping drives from non domain pcs via scripts

    Does anybody have a script (or know an app that will do it) that will prompt for a username and password then query Active Directory to find the users homedrive and then map the drive on the PC?

    As I want to be able to remove some of our class sets from the domain as 90% of the time they just use it for web browsing which will be alot quicker from power on to being usable for students.

  2. #2
    MaceZ4's Avatar
    Join Date
    Dec 2010
    Location
    Lots of different places...
    Posts
    129
    Thank Post
    12
    Thanked 12 Times in 8 Posts
    Rep Power
    10
    Ok maybe someone can pick up from this and figure out how to tie it in with AD...

    I use bat files to map drive for people that don't have/want domain attached machines.

    Code:
    net use X: \\server\folder\ /user:domain\userid password
    Change where it says "server" to the name of the server, "folder" to the location and you can keep digging as deep as needed so as to tie into people's storage drives.

    Then replace "userid" with the login name and "password" with their password.

    Yes it's simple and boring to make loads of these, but it has served well for me

  3. #3

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,817
    Thank Post
    272
    Thanked 1,138 Times in 1,034 Posts
    Rep Power
    350
    Quote Originally Posted by MaceZ4 View Post
    Ok maybe someone can pick up from this and figure out how to tie it in with AD...

    I use bat files to map drive for people that don't have/want domain attached machines.

    Code:
    net use X: \\server\folder\ /user:domain\userid password
    Change where it says "server" to the name of the server, "folder" to the location and you can keep digging as deep as needed so as to tie into people's storage drives.

    Then replace "userid" with the login name and "password" with their password.

    Yes it's simple and boring to make loads of these, but it has served well for me

    Yeah I have that part as have been given a autoit script from somebody at another school but not all my users are on the same file server which is where I need the AD query for the homepath.

    So far i have

    Code:
    Local $Username, $Password, $Result, $Flag
    
    $Flag = 0
    
    RunWait("cmd /c net use w: /DELETE")
    RunWait("cmd /c net use p: /DELETE")
    
    Do
    	if $Flag = 1 Then
    		MsgBox(0,"Error","Your username or password were incorrect. Please try again")
    	EndIf
    
    	$Flag = 1
    	$Username = InputBox("Logon to Network Drives", "Please enter your username:","","",150,80)
    
    	if $Username = "" then
    		Exit
    	endif
    
    	$Password = InputBox ("Logon to Network Drives", "Please enter your password:","","!",150,80)
    
    	if $Password = "" then
    		Exit
    	endif
    
    	$Result = RunWait("cmd /c net use N: \\server\share " & $Password & " /USER:" & $Username & " /PERSISTENT:NO")
    	$Result = RunWait("cmd /c net use R: \\server\sharedarea " & $Password & " /USER:" & $Username & " /PERSISTENT:NO")
    
    Until $Result = 0 AND NOT @error
    Exit
    I just need to find something i can use for a query to ad to output to say $homedrive

    then add the variable to the $result instead of \\server\share

    Toby

  4. #4
    michaelf's Avatar
    Join Date
    Jun 2007
    Location
    Kettering, Northants
    Posts
    81
    Thank Post
    7
    Thanked 13 Times in 10 Posts
    Rep Power
    17
    Quote Originally Posted by glennda View Post
    I just need to find something i can use for a query to ad to output to say $homedrive

    then add the variable to the $result instead of \\server\share
    It's been a while since I've used AutoIt but what about this for a slightly different way of looking at the problem.

    Instead of using RunWait to launch an external command to map the drive, why not use AutoIt's DriveMapAdd command instead? The advantage here is that if it fails it will return an @error code showing the reason. You could then write an IF loop to try out the different places where the homedrive could be stored until it finds one that exists.

    Secondly I believe that one of the @error conditions also flags an incorrect password allowing you to provide a friendly prompt in the case of typos.

    Not the cleanest way I know but it might just work?

  5. #5

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,817
    Thank Post
    272
    Thanked 1,138 Times in 1,034 Posts
    Rep Power
    350
    Yes drive mapadd until it finds one was a suggestion somebody else made - although having each year group on a different share it could take forever to find one. As we would have

    \\FS1\INTAKE10$\USERNAME
    \\FS2\intake10$\username

    And on for each year group 7-13 across 6 file servers the users at the bottom might be there a week!

  6. #6

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,817
    Thank Post
    272
    Thanked 1,138 Times in 1,034 Posts
    Rep Power
    350
    having just seem this thread

    some of the software mentioned there might also work - i'll look into it further next week.

    but my prefered method would be a script of somesort

  7. #7

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,817
    Thank Post
    272
    Thanked 1,138 Times in 1,034 Posts
    Rep Power
    350
    Just wondering if anybody else has any thoughts to this as i'm stumped as can't find anything i can use - although I think it must be do able.

  8. #8

    Join Date
    Jun 2010
    Location
    Bury
    Posts
    82
    Thank Post
    9
    Thanked 9 Times in 9 Posts
    Rep Power
    10
    I could probably whip up something in VBScript if you want. The only problem I foresee is the password box; does your current script mask the passwords with dots or asterisks?

  9. #9

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,817
    Thank Post
    272
    Thanked 1,138 Times in 1,034 Posts
    Rep Power
    350
    Quote Originally Posted by JHeaton View Post
    I could probably whip up something in VBScript if you want. The only problem I foresee is the password box; does your current script mask the passwords with dots or asterisks?
    If you could that would be great - never really played with vbs.

    Currently it uses this line
    Code:
    $Password = InputBox ("Logon to Network Drives", "Please enter your password:","","!",150,80)

    and hides text input with !

    Cheers

  10. #10

    Join Date
    Jun 2010
    Location
    Bury
    Posts
    82
    Thank Post
    9
    Thanked 9 Times in 9 Posts
    Rep Power
    10
    Okay, I'm not 100% sure that VBScript can do that, but I should be able to find a solution. I'll get back to you in a day or so.

  11. #11

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,817
    Thank Post
    272
    Thanked 1,138 Times in 1,034 Posts
    Rep Power
    350
    cheers

  12. #12

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,817
    Thank Post
    272
    Thanked 1,138 Times in 1,034 Posts
    Rep Power
    350
    If not just a vbscript which can query ad and get me the Homedirectory path for a user. I might be able to then play with autoit to get the username/password into it.

  13. #13

    SimpleSi's Avatar
    Join Date
    Jun 2005
    Location
    Lancashire
    Posts
    5,822
    Thank Post
    1,476
    Thanked 593 Times in 445 Posts
    Rep Power
    168
    Just an idea - are you usernames mapped to user folder names in any sort of logical way

    e.h user jsmith11 - user folder is \\server\pupils\2011leaver\jsmith ??

    Then you wouldn't need to query AD.

    regards

    Simon
    PS I would imagine that a non-domain machine wouldn't be able to access AD info for security reasons BTW

  14. #14

    Join Date
    Jun 2010
    Location
    Bury
    Posts
    82
    Thank Post
    9
    Thanked 9 Times in 9 Posts
    Rep Power
    10
    Quote Originally Posted by SimpleSi View Post
    Just an idea - are you usernames mapped to user folder names in any sort of logical way

    e.h user jsmith11 - user folder is \\server\pupils\2011leaver\jsmith ??

    Then you wouldn't need to query AD.

    regards

    Simon
    PS I would imagine that a non-domain machine wouldn't be able to access AD info for security reasons BTW
    Not querying AD would be much, much easier, although it is possible to query AD from a non-domain machine. The problem I came across when doing research on it last night is that it requires a set of credentials for an account that is able to query AD in the script, which might cause a potential security issue.

  15. #15

    glennda's Avatar
    Join Date
    Jun 2009
    Location
    Sussex
    Posts
    7,817
    Thank Post
    272
    Thanked 1,138 Times in 1,034 Posts
    Rep Power
    350
    Quote Originally Posted by JHeaton View Post
    Not querying AD would be much, much easier, although it is possible to query AD from a non-domain machine. The problem I came across when doing research on it last night is that it requires a set of credentials for an account that is able to query AD in the script, which might cause a potential security issue.
    hmm - can it not use the credentials which will be inputed? As each user has the rights to view their own personal information as they need to be able to see their home directory/profile paths etc

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

Similar Threads

  1. Drive mapping issues in logon scripts
    By Bruce123 in forum Windows
    Replies: 10
    Last Post: 20th September 2009, 12:22 PM
  2. Mapping local drives (not network drives)
    By Pyroman in forum How do you do....it?
    Replies: 4
    Last Post: 11th June 2008, 03:19 PM
  3. mapping drives
    By rjsmith in forum *nix
    Replies: 2
    Last Post: 14th November 2007, 05:42 PM
  4. mapping drives
    By chrbb in forum Wireless Networks
    Replies: 3
    Last Post: 3rd November 2007, 03:18 PM
  5. Mapping network drive without using Scripts
    By tazz in forum How do you do....it?
    Replies: 13
    Last Post: 5th October 2007, 03:18 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
  •