Adding a homedirectory drive letter in a batch script

I have written a batch script which sets up a bunch of user accounts but have just realised the functionality of the NET USER command is somewhat restrictive in as far as one is unable to specify a network drive letter for the homedirectory. Does anyone know of a utility that includes this functionality?

If the environment is all Windows XP then you can this with the "set" command - this is built in. I think it is also in Windows 2000, but I had some problems with it.

Set Homedrive=U:\
Set Homepath=\

If it is a mixed environment then you will need the "setx" Resource Kit utility.

If you are using setx don't forget to put the actual exe file in to netlogon share along with the batch file so that the logon script finds it.

Simon.

0

The__SaintAuthor Commented: 2004-09-06

Sorry, I think I need to clarify slightly.
For the record this is an AD environment but the problem I have applies just as much to an NT environment. What I want to change are the properties of a user account, hence the example I used with NET USER. NET USER will change the script path for a user account, the profile path and the local drive path for the homefolder amongst other things. However I am unable to make it select the 'Connect' path and specify a drive letter. NET USER won't allow this but I find it difficult to believe there isn't a utility out there which provides this functionality.

This would have been perfect had the user accounts not been already created! The users in question had the accounts themselves created a few months ago in order to use webmail and now they are going live properly. Therefore I need a utility which will manipulate an existing account.

It will do batch changes to user accounts, which is what you are looking for.

Hope this helps...

0

The__SaintAuthor Commented: 2004-09-07

Cheers but it looks like the lite version is limited to only 5 users at a time and is a little much for what I need. Specifically I would like a command line utility. Sorry to be picky!

Cheers

Simon

0

The__SaintAuthor Commented: 2004-09-07

I have selected all users within the OU I wish to change and changed the drive letter en mass (which I hadn't realised initially I could do). This has fixed my issue. I've still not found a command line utility though.

I knocked up the followed command file to move home directories for around 150 staff. Scripting it really cuts down on unneccesary errors due to typos/tiredness

rem copyhome.cmd by Hans Stiles
rem Script to copy contents of home directory from SERVERA to SERVERB
rem share new on SERVERB directory, set share and file permissions
rem modify home directory information for the user account
rem and then unshare old directory on SERVERA

I realise there is more code than you need here, but I thought the entire fiule would give you an idea of how you could create a command file that called a vb script. I basically dumped a list of all users in to a text file and setup a command file as follows:

copyhome usera
call copyhome userb
call copyhome userc

kicked it off when I got home, went out for the evening, came home, cleared up any errors, claimed a day off in lieu :)

Since you've mentioned AD, plus you said you were able to select multiple users, you're running a W2k3 domain.
If you have the W2k Resource Kit, you can use cusrmgr.exe from there to change the drive letter using a command line.
In addition, MS finally came up with some nice AD command line tools in W2k3., that you can use as well.
dsmod.exe user <User-DN> -hmdrv H:
To obtain the user dn (which you probably won't want to type), you can use dsquery:
dsquery.exe user -samid <Username>
These can be combined in a batch script:

This is just what I was looking for. I hadn't realised cusrmgr went much further than passwords (should have checked, but you forget about these things) although this must be run on the domain controller. DSMOD in particular looks very useful so thanks and thanks as always to everyone who has contributed.

Featured Post

Managing email signatures in Office 365 can be a challenging task if you don't have the right tool. CodeTwo Email Signatures for Office 365 will help you implement a unified email signature look, no matter what email client is used by users. Test it for free!