Question

share and re-share a folder. I got the re-sharing part where i am stuck at is the un-sharing.

I use this code

NET SHARE d:\foldername /delete

Which deletes the share but if there are people accessing the folder there is prompt to continue, now i want this batch file to run silently without any prompts. Any thoughts ?

Was it helpful?

Solution

This is the easier one i figured :)

NET SHARE d:\foldername /Y /delete

OTHER TIPS

Put this into a file yes.txt

Y [Newline]

now

type yes.txt | NET SHARE d:\foldername /delete

There is actually NO need to mention full path.Windows will figure it out itself and delete. Also there is no accidental chance of deletion of two folders w/ same name @ different locations , because that's just not allowed. You have to give different Share names. so this will work just fine "Shard" is a folder on my desktop

NET SHARE  foldername /Y /delete

See the Use cases demo below

    C:\Users\Administrator>net share \\w7\*  /y /delete
This shared resource does not exist.

More help is available by typing NET HELPMSG 2310.


C:\Users\Administrator>net share \\w7\users  /y /delete
This shared resource does not exist.

More help is available by typing NET HELPMSG 2310.


C:\Users\Administrator>net share c:\users  /y /delete
Users was deleted successfully.

c:\users was deleted successfully.


C:\Users\Administrator>net share c:\  /y /delete
C$ was deleted successfully.


c:\ was deleted successfully.


C:\Users\Administrator>net share c:\shard /y /delete
A matching share could not be found so nothing was deleted.

More help is available by typing NET HELPMSG 3719.


C:\Users\Administrator>net share shard /y /delete
shard was deleted successfully.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top