Question

Locked

Writing a windows script for the net use command

By angeln186 ·
Hi guys,

I am a total newbie when it comes to windows scripts. I really need a script to just mount a shared folder.

So if you guys could help me out with the basics of scripting, that would be awesome. For instance i can type "net use" in the command prompt and get a list of shares im connected to. How do i put that command in a script file? I have tried just writing net use in a text file (which i renamed to a vbs extension) but no luck.
I have tried the full pathname (C:\windows\system32\net.exe use) but still did not work.
What am I doing wrong?

Thanks

Nitin

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

net use

by Churdoo In reply to Writing a windows script ...

Well if all you're trying to do is map a share, then you don't really need scripting, just a BATCH file (.bat or .cmd). Are you trying to map a drive letter to a given share? If so,
net use x: \\servername\sharename

net use /? will display a help screen giving you more information on the net use command.

Once you get your desired results from the command line, then copy the correct command into a .bat or a .cmd file. I may recommend using the preceeding example:

@net use x: /d >nul
net use x: \\servername\sharename

This will disconnect the drive letter x: (and if x: is not connected, will produce an error which you won't see cuz it's redirected to the nul device, then will connect the drive letter to the proper share)

Hope this helps. If so, send me a Pepe's pizza.

Collapse -

It worked, thanks a lot

by angeln186 In reply to net use

Thanks to both of you. The .bat file worked like a charm and it was exactly what i needed. Something that could run command prompt commands but in a file.

Thanks a lot

Collapse -

rename the file to

by Dumphrey In reply to Writing a windows script ...

.bat not .vbs, and make sure its really renamed and not .bat.txt (ie show file extensions is enabled).

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums