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?

link|improve this question

69% accept rate
feedback

1 Answer

up vote 6 down vote accepted

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

link|improve this answer
I am not entirely sure why, but the batch file with that first line opened about 100 windows... – AaronLS Feb 9 '10 at 22:06
3  
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 '10 at 22:09
1  
@aaronls That is hilarious:) – phoebus Feb 9 '10 at 22:13
Sorry, should have been more specific. Perhaps you should use net.exe use next time... proof you can never assume anything. – heavyd Feb 9 '10 at 22:48
You want a hilarious bat file? create a .bat file with this as the only contents, and then run it: %0|%0 – davr Feb 10 '10 at 2:38
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.