Net.exe Can Use Hidden Switches /Y /N for Unconditional Yes/No

Article translations Article translations
Article ID: 156458 - View products that this article applies to.
This article was previously published under Q156458
Expand all | Collapse all

SUMMARY

When you use Net.exe commands in a batch file, you can use the Y or N switch to unconditionally answer Yes or No to questions returned by the Net command.

MORE INFORMATION

Normally, you could pass a "Y" using Standard-in through redirection as in the following example:
   delshare.bat file contents:
   NET SHARE TOOLS /D  <y.txt

   Y.txt file contents:
   Y(cr) carriage return
				

But the following error occurs using this method when the Delshare.bat file is run and fails the operation.
NET SHARE TOOLS /D <y.txt
Users have open files on TOOLS. Continuing the operation will force the files closed.

Do you want to continue this operation? (Y/N) [N]:
No valid response was provided.

WORKAROUND

Change your batch file to include the Y switch to unconditionally answer Yes to the question "Do you want to continue this operation? (Y/N) [N]:"
   Delshare.bat new contents:
   NET SHARE TOOLS /D /Y
				

After running this batch file, you will receive the following message:
   NET SHARE TOOLS /D /y
   Users have open files on TOOLS. Continuing the operation will force the
   files closed.

   TOOLS was deleted successfully.
				

Properties

Article ID: 156458 - Last Review: March 29, 2004 - Revision: 3.0
APPLIES TO
  • Microsoft Windows NT Advanced Server 3.1
  • Microsoft Windows NT Workstation 3.1
  • Microsoft Windows NT Workstation 3.5
  • Microsoft Windows NT Workstation 3.51
  • Microsoft Windows NT Workstation 4.0 Developer Edition
  • Microsoft Windows NT Advanced Server 3.1
  • Microsoft Windows NT Server 3.5
  • Microsoft Windows NT Server 3.51
  • Microsoft Windows NT Server 4.0 Standard Edition
Keywords: 
kbusage KB156458

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com