Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On a Windows 2008 R2 Server (Standard) I need to have a network drive mounted without having a specific user to log on to the machine first. Sort of like an NFS mount via fstab on Unix machines. The network drive will be a share via a BlackArmor (Seagate) appliance (which I presume runs Samba). The appliance can be a member of the domain if needed.

So far I have tried using Edit Group Policy -> Configuration -> Windows -> Scripts -> Startup where I had it execute

net use x: \\server\share /user:username password

With no success. Upon login the network drive was seen on Windows Explorer as a disconnected network drive.

share|improve this question
1  
Are you looking to have it available to anyone who logs in to that server, or does it need to be on a specific drive-letter for some system-service? –  sysadmin1138 Sep 11 '12 at 11:39
    
I need it to be on a specific drive letter for use by applications that run as a service on the machine. I cannot have the service execute a "net use" upon starting up :( –  adamo Sep 11 '12 at 11:50
    
Have you tried editing the Local Computer Policy Settings and getting the script to run at start-up, from Computer configuration->Windows Settings->Scripts ? –  thanosk Sep 11 '12 at 12:03
add comment

2 Answers

create its batch file, which runs this command. convert it to a windows service. make that service start at windows startup, and thats it.

It might be helpful: How to create a service running a .bat file on Windows 2008 Server?

share|improve this answer
    
seems like you took my word LITERALLY.. Do yo think a logon is required for windows service to run? i did a typo mistake, which i have corrected –  Farhan Sep 11 '12 at 12:15
add comment

This apparently possible, according to this StackOverflow post.

Before posting the content of the answer, however, can I suggest that you're over-complicating this?

In situations like this where some crappy piece of code needs a user logged on to run (like Domino server, grumble) I've created a service account that's to always be logged in on a given server, and setup an auto-login script, so that the machine logs in the specified account on reboot automatically. I'd suggest that the easier, and more supportable solution to your problem would be to do the same, and have the drive mapped for that service account user by Group Policy or logon script.

Anyway, should you be determined to try this without a user context, see the below. It's a hack, so use at your own risk and all:

For this hack you will need SysinternalsSuite by Mark Russinovich: http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx

Step one: Open an elevated cmd.exe prompt (Run as administrator)

Step two: Elevate again to root using PSExec.exe: Navigate to the folder containing SysinternalsSuite and execute the following command "psexec -i -s cmd.exe" you are now inside of a prompt that is "nt authority\system" and you can prove this by typing "whoami". The -i is needed because drive mappings need to interact with the user

Step Three: Create the persistent mapped drive as the SYSTEM account with the following command "net use z: \servername\sharedfolder /persistent:yes"

It's that easy!

WARNING: You can only remove this mapping the same way you created it, from the SYSTEM account. If you need to remove it, follow steps 1 and 2 but change the command on step 3 to: "net use z: /delete"

NOTE: The newly created mapped drive will now appear for ALL users of this system but they will see it displayed as "Disconnected Network Drive (Z:)". Do not let the name fool you. It may claim to be disconnected but it will work for everyone. That's how you can tell this hack is not supported by M$.

From comments:

To get it working after a reboot, create a script just containing net use z: \servername\sharedfolder and set it to run on computer startup, per technet.microsoft.com/en-us/library/cc770556.aspx This will run as the SYSTEM account, so no need for psexec.

share|improve this answer
    
Using a network share with username and password this doesn't seem to work. I see the "Disconnected Network Drive" but am not able to access it "Wrong User Name and Password". –  spankmaster79 Jun 20 at 14:19
    
@spankmaster79 <shrug> Not sure why you'd get that error (account lockout, maybe?), but if you have a new or related question, I'd recommend asking it as a question on the main site, instead of commenting here. –  HopelessN00b Jun 20 at 14:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.