34

I would like to make a batch file that:

  1. Opens cmd.exe
  2. Within that Command Prompt runs net use to display mapped share paths
  3. Leaves the window open so that I can run additional commands if I wish to

How can I do this?

1 Answer 1

46

Put in your batch file

start cmd.exe /k "net use"

From cmd /?

Starts a new instance of the Windows XP command interpreter

CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF] [[/S] [/C | /K] string]

/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains

8
  • 1
    I am not entirely sure why, but the batch file with that first line opened about 100 windows...
    – AaronLS
    Feb 9, 2010 at 22:06
  • 17
    Oh, I know why, I named my batch file "net use.bat", and therefore cmd.exe tried to run "net use" and found the batch file first since it was the closest, therefore it was recursively running the batch file. LOL :()
    – AaronLS
    Feb 9, 2010 at 22:09
  • 4
    @aaronls That is hilarious:)
    – phoebus
    Feb 9, 2010 at 22:13
  • 1
    Sorry, should have been more specific. Perhaps you should use net.exe use next time... proof you can never assume anything.
    – heavyd
    Feb 9, 2010 at 22:48
  • 3
    davr's "hilarious" batch file quickly brought my Win 7 machine to a halt. It wouldn't respond to Ctrl+Shift+Esc, Ctrl+Alt+Delete, Ctrl+Break etc. Make sure your documents are saved first.
    – Qwertie
    Mar 21, 2012 at 23:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .