1

I want a batch file to open CMD and run "net stop audiosrv", then "net start audiosrv", then kill CMD. I am having problems with a bunch of things including

  • It's not waiting
  • It is opening a new CMD
  • It's not closing

Here is the code I wrote myself. I've never done any coding before and got this from what I did now/combining it with other things I've seen on here.

start cmd.exe /k "net stop audiosrv"

wait 10

start cmd.exe /k "net start audiosrv"    

TASKKILL /IM cmd.exe

I don't really think it matters but I'm running Windows 7 Ultimate Service Pack 1 - 64 bit

Dave
  • 25,405
  • Your question is missing lots of detail. how are you executing the command? Via command line or a .bat file or some other means? – Dave Sep 12 '14 at 13:54
  • Hey thanks @Dave! I didn't know you could do it via just bat without opening cmd. I ending up removing the "start cmd.exe" portion, and then since I didn't open a cmd I could remove the TASKILL part, leaving me with a working:

    `net stop audiosrv

    wait 10

    net start audiosrv `

    – ShadyShroomz Sep 12 '14 at 13:59

2 Answers2

0

Got it working! Credit to @Dave

net stop audiosrv
net start audiosrv
0

The code seems fine but it looks like you're sending this command at a time.

Save it to a bat file and execute it from there, you'll probably see it works fine (although you will need to not include things like the start cmd.exe obviously)!

Dave
  • 25,405