Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I need to close existing connections and want to do that with the command
CMD with parameters "net use * /delete"
BUT: I cant figure out what should be the right syntax...

It also should execute without asking confirmation as it normally does in CMD...

What I have tried:

I have now: (but it does not work...)
Process.Start("CMD", "net use * /delete")
Posted
Updated 27-Dec-17 9:26am

Try this:
VB.NET
Process.Start("CMD", "/c net use * /delete")
The /c switch tells cmd to execute the command that's after the switch.
 
Share this answer
 
Comments
CDRxxx 27-Dec-17 15:33pm    
Thx for this! Works fine...but do you know also how to make it autoexecute? (For now net use waits for confirmation to delete connections...)
Thomas Daniels 27-Dec-17 15:34pm    
Try adding an additional /y switch at the end of the net command.
PIEBALDconsult 27-Dec-17 21:11pm    
Is that where it goes? I wound up using ECHO Y | NET USE ...
Thomas Daniels 28-Dec-17 2:35am    
I think so; I found that in this Stack Overflow answer.
CDRxxx 28-Dec-17 9:35am    
Thx for your help!! this is exactly what I was looking for, I mean the /Y ...
My solution looks now like
Process.Start("CMD", "/c net use * /delete /Y")
and it works as it shoud.
Found this:
"https://stackoverflow.com/questions/10261521/how-to-run-dos-cmd-command-prompt-commands-from-vb-net" target="_blank" title="New Window"

and this works fine but the question about 'not asking confirmation' remains...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900