Pashers Posted June 6, 2008 Posted June 6, 2008 Hello! I'm new to creating batch files and at the moment I have the following command: dsquery user domainroot -name %1 | dsget user -hmdir %1 being the pupil's username. It queries the AD, and returns with the home directory of the pupil. However, I'm wishing to open this folder. I've tried the following with no joy: start dsquery user domainroot -name %1 | dsget user -hmdir start | dsquery user domainroot -name %1 | dsget user -hmdir dsquery user domainroot -name %1 | dsget user -hmdir | start Many thanks for your help!
Michael Posted June 6, 2008 Posted June 6, 2008 I'm not sure about your script, but I presume you know you can do this with Folder Redirection in Active Directory? Relatively simple to setup and reliable too.
Pashers Posted June 6, 2008 Author Posted June 6, 2008 I've currently created an Access database (linking into the library database for the pupils information) which changes the pupils password automatically after they scan in their library card. Also forcing them to change the password at logon. Due to this, I thought it would also be a good idea to add a feature for admin, to open their home directory folder without the need of accessing AD, or the use of opening another program/document. The only reason I'm doing it as a .bat is because it's a quick easy fix and makes my life easier than even trying to do a VBA code for it :-)
Michael Posted June 6, 2008 Posted June 6, 2008 I understand Sounds like you're working on a nice project there!
srochford Posted June 6, 2008 Posted June 6, 2008 What format are you getting the username in? If you've got the full distinguished name in a variable called sDN then you can use: set oShell=createobject("wscript.shell") set oUser=getobject("LDAP://" & sDN) oShell.run oUser.homedirectory in your VB code. If you just have the samaccountname then you can do set oShell=createobject("wscript.shell") set oUser=getobject("WinNT://" & sDomain & "/" & sUser) oShell.run oUser.homedirectory (where sUser is the username and sDomain is the NetBIOS name of the domain)
srochford Posted June 9, 2008 Posted June 9, 2008 sure; sometimes it's useful to have a comparison of various methods - that way you can work out what suits. batch file method is good because the commands can just be typed at the prompt which sometimes makes life easier if it's a one-off.
Pashers Posted June 9, 2008 Author Posted June 9, 2008 The format is just the login name, each year group has a different OU. That's why I've done a lookup for the user's ou then piped it into the reset password section. The only reason I went with .bat is because it's quick and easy. Maybe 'dirty' but easy, I like it when things are easy! If there is a more efficient way using VB Script, please tell me. I just thought it would be difficult to do the same thing?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now