Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#362260 - 23/07/2014 18:24 Net Use
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
Is there someone here who can help me troubleshoot a "net use" command?

I'm trying to walk through a set of instructions provided by Crashplan to mount a NAS as the system user so Crashplan can back that NAS up. So far, I haven't had any luck getting it to work.

The task is scheduled fine and I can tell that it's running, but it's just not creating the mapped drive. Here is the content of the batch file I've scheduled:

Code:
net use Z: \\192.168.1.21\ /USER:192.168.1.21\USERNAME PASSWORD C:\other\mount.log 2>&1 
2>&1

I've tried simplifying that to take out the logging part but that doesn't help. I also don't understand what the "2>&1" part does or why there are two of them.

Is this correct? If so, why might it be failing? Thanks for your help.


Edited by Dignan (23/07/2014 18:54)
_________________________
Matt

Top
#362261 - 23/07/2014 18:33 Re: Net Us [Re: Dignan]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
It's just like old times on the empeg board. I post a question about something I've been dealing with for a day or more, and I immediately make progress on it.

I finally realized that I should test it out by opening a command prompt and running the batch file manually. First it complained about my syntax, so I took out everything after "PASSWORD." Then it technically worked, but it informed me that the path wasn't found. I figured that might be a problem, so I added "photos" to the end of "net use Z: \\192.168.1.21\" and that worked.

So I get that the net use command wants "devicename\sharename" but is there any way to leave the share name blank? I'd hoped to be able to map a drive that could show all the shared folders for that device...
_________________________
Matt

Top
#362262 - 23/07/2014 20:02 Re: Net Us [Re: Dignan]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
The 2>&1 is trying to tie both STDERR and STDOUT to the same thing so that it can either log both, or deliberately fail to log both, to either a logfile or to the screen. Here's some stuff I had stored that I had previously found on the internet somewhere:

Quote:

There are two main output streams that you usually see on the console, stdout and stderr. When you do a > "some file name", it redirects stdout to the file. But stderr still comes to the console. 2>&1 binds stderr to stdout so that all the output is redirected. You see it more often in Unix shell scripts.

Example:

reg export "%REG_SOFTWARE_ROOT%\%PRODUCT_NAME%" "%TEMP_DIAG_OUTPUT%\ProductStuff.reg" > NUL 2>&1


I think the problem with your original syntax after the PASSWORD is that it was missing the chevron to redirect to the log file. I think the original example meant to do something like this:
PASSWORD > C:\other\mount.log 2>&1

But you lost the chevron in a cutNpaste somewhere, so it did this instead:
PASSWORD C:\other\mount.log 2>&1
... Which is syntactically wrong for the NET USE command.

I'm not sure if any of the above works as-I've-typed-it, I'm just pasting stuff in to get the point across.

To the other question about how to do NET USE without needing the share name... There may be something like IPC$ or something that you can put in place of the share name there. Dig around what SS64 has to say about net use, I've always found their stuff more helpful than the plain DOS HELP command:

http://ss64.com/nt/net_use.html

If that doesn't help, try eschewing NET USE altogether, and just cache those user credentials into the system's existing cache of passwords so that they Just Work when the guy opens the share. Like this:

Cmdkey /delete:SERVERADDRESS
Cmdkey /add:SERVERADDRESS /user:USERNAME /pass:PASSWORD

The beauty of this is that you can do it more than once store multiple ones just in case you don't know whether they'll be using the IP address, the FQDN, or the server name without FQDN. Like this:

Cmdkey /delete:192.168.1.21
Cmdkey /add:192.168.1.21 /user:USERNAME /pass:PASSWORD
Cmdkey /delete:SERVERADDRESS
Cmdkey /add:SERVERADDRESS /user:USERNAME /pass:PASSWORD
Cmdkey /delete:SERVERADDRESS.domain.com
Cmdkey /add:SERVERADDRESS.domain.com /user:USERNAME /pass:PASSWORD


To have a looksee at what windows credentials are cached, run:

CONTROL KEYMGR.DLL

And click on "Windows Credentials".


Caching those credentials is great if you don't intend to change the passwords. If the passwords change, though, then if you keep hammering the server with the wrong cached creds it'll lock you out. I run into this on my test machines at work all the time, they keep making me change my password so I have to go use a script file with the CMDKEY thing to poke the creds into the test computers before they hammer the server with the wrong cached credentials and lock out the account.
_________________________
Tony Fabris

Top
#362263 - 23/07/2014 20:14 Re: Net Us [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
I just followed your link to the Crashplan help doc and you're right, their syntax is messed up for Net Use. I think there's some typos in their examples.

I see that you're trying to map a DRIVE LETTER to a share. If you want to do that, then you really do need the SHARE NAME in the net use command. Think of it like this.

The share name represents a folder on that server. If the server has more than one share you can get a list of the shares, but a list of the shares is not the same thing as the server's root directory. For example the server might have folders like this:

Photos
Program Files
Documents
bin
etc
Windows
shell
Videos

With the bold items being the folders that you have shared. But the thing is, looking at a list of those shares is not the same thing as going to that computer's root directory. In fact, those share's don't even have to be in the root at all. Maybe they have a folder that's six levels deep and they only shared a subfolder of that folder. Whereas somewhere else they shared something at the top level.

In any case, for users connecting to the server, you only want them to access the SHARES, not all the folders in the root. So by default, if you browse to the server name, you can see a list of its shares, but you cannot map THAT VIEW to a drive letter. It wouldn't make sense to do that because you would be unable to save files to its root directory... there IS no root directory.

Once you're down to the level of one of the SHARES then yes, you can make that the root directory of a mapped drive and that will work.

Is that helping to make it clear why NET USE doesn't work without a share name after the computer name?
_________________________
Tony Fabris

Top
#362264 - 23/07/2014 20:16 Re: Net Us [Re: tfabris]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31563
Loc: Seattle, WA
(I am of course glossing over the ability for a Windows computer to share its root C: drive if desired, and the default administrative share of "C$" which exists by default on all windows systems. But that, when you connect to it, is still an actual folder with actual files and stuff that you can still write to, that's different than a LIST OF THE SHARES.)
_________________________
Tony Fabris

Top
#362265 - 24/07/2014 03:26 Re: Net Us [Re: Dignan]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
Thanks a ton, Tony! You're giving me a really good understanding of this command.

Really, when I was hoping for a way to perform net use without a sharename, I was really just trying to save some effort and create a single backup drive mapping. In the end, I disconnected all my mapped drives that I'd made under my user account, and had them all get added through this batch file.

In the end, I decided to go with whatever makes Crashplan work with my NAS. You're right, I don't think the syntax of the document was correct to start with. But I simplified it greatly and got it to work.

Thanks again for your help and information!
_________________________
Matt

Top
#362268 - 25/07/2014 08:42 Re: Net Us [Re: Dignan]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
I think you've already figured this out but NET USE can only map to a share, not to a server with the shares as folders below it.

The C$/D$/E$ admin share is your only hope but then you have to dig out the specific share locations.

2>&1 just pipes stderr into stdout. That should come before the >>mount.log part which is why it's done - so that stderr goes into the log file.

The Crashplan example was right except for the redirection and logging part.
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#362269 - 25/07/2014 14:17 Re: Net Us [Re: Dignan]
Dignan
carpal tunnel

Registered: 08/03/2000
Posts: 12318
Loc: Sterling, VA
Thanks guys. Yeah, I figured the share was required. Mapping the drives this way is a little less elegant than just mapping them through my user account, and it's caused some weirdness, but for the most part it's fine and it's backing up now.
_________________________
Matt

Top