Net use Command : Windows CE

Werner van den Heever picture Werner van den Heever · Jul 1, 2014 · Viewed 24.6k times · Source

I'm trying to send network credentials using Net Use command.

This is what I have:

@echo off
net use \\<serverName>\<shareFolder>\ passw0rd /USER:domain.com\UserName
PAUSE

This automatically inserts the username and Domain but for some reason not the password!!

I have tried it like this as well:

@echo off
net use \\<serverName>\<shareFolder>\ /USER:domain.com\UserName passw0rd 
PAUSE

I have checked the paths I'm using and they definitely work. When i copy them out and paste in RUN they work.

Same goes for the username and passwords.

Everything in google search is purple cause I've clicked on all the links :/


Ok, I thought I had it...

I tried it like this:

@echo off
net use \\<serverName>\<shareFolder>\ <mapName> /USER:domain.com\UserName passw0rd 
PAUSE

And it worked, but only because i entered the password before i tried it like this and then it remembered the password.

So I'm still looking for a way.

Please help.

Answer

Mofi picture Mofi · Jul 2, 2014

Does the password contain special characters like % / ~ or similar characters with special meaning in batch files?

Yes, then enclose the password in double quotes.

Use also double quotes around UNC path and test if that makes a difference.

What I miss in all your net use commands is the device name usually specified left of UNC path to shared folder to map the shared folder to a drive letter. Therefore it could be that the password is interpreted as device name.

But according to your question you want to pass only the user credentials and password to be able to access the shared folder using UNC path. However, I suggest to test if it makes a difference really mapping the shared folder to a drive letter. I don't know if the password string is interpreted as device name if no device name specified and can't test it by myself at the moment.