Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch: map network NET USE

Status
Not open for further replies.

vietboy505

Technical User
Feb 20, 2006
56
US
I wrote a batch script to mount the network automatic at startup. It doesn't allow to map as drive.
I used:

mount.bat
Code:
NET USE \\SERVER
Will output..
The command completed successfully.

Now I have a problem with that,
When I checked NET USE:

Disconnected \\SERVER\IPC$ Microsoft Windows Network
The command completed successfully.

It never connect at all, how can I make sure it's connect, and if it's disconnected.
Remap it.
 
You're just making a quick connection there, not "mapping" anything. All that does is say "Hi, I'm here. Goodbye." to the server.
What are you trying to do exactly? Mount a network share? If so, the command should be something like:

net use x: \\server\share

where x: is the drive letter of your choice.
 
I don't want to the drive, but sometimes with drive it's disconnected too.

I just want to use \\server\path only.
 
You can use that directly just access \\server\path

The answer has always been 42
 
I know that, but sometimes I get disconnect.

And NET USE \\server\path again will not work connect.

I have to delete the path and do a net use again.

I was wondering if there is a command to determine the network is still running, then if not, delete it, and map it again without doing it mannual.

That why I wrote that batch script to automatic to map network at start up except it can't successfully map unless it been mapped and disconnected.
 
You need to look at the return code of the NET USE command before proceeding.

In batch programming you do this by putting the statement:
Code:
if errorlevel x <command>

This will evaluate the return code of the previous command and perform <command> if that error level or higher was encountered. Normally a return code of 0 means success.

Commonly you would use a GOTO statement following this type of error checking so that you can execute a series of commands, not just one.


pansophic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top