Solved

Hiding Output in Batch File Script

Posted on 2007-11-30
5
6,515 Views
Last Modified: 2009-02-09
From :
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/NT/Q_10698621.html?sfQueryTermInfo=1+batch+error+file+hide+script
I see how to hide the output in a batch file.
Do I need to add that code to each line for which I want to hide the output, or can I add it to one place in the script?  (For Win XP)
0
Comment
Question by:NCHCIT
5 Comments
 
LVL 5

Accepted Solution

by:
usarian earned 250 total points
Comment Utility
ECHO OFF
{secret stuff}
ECHO ON
you can also use >> {filepath/filename}
to create a text file as a log.  That process also hides all output while the script is running.

OR

switch to vbscript/jscript
0
 

Author Comment

by:NCHCIT
Comment Utility
I've got ECHO OFF preceding all commands in the script, but it only hides the commands.  When I use an ATTRIB command on a directory, not wanting to change the attributes for hidden files, I get a ton of output for all hidden files whose attributes are not being changed, regardless of the ECHO OFF command.
Using >> (would that be considered a switch or command or something else?) took care of the job nicely.
Do I need to use that for every command whose output I want to hide?
0
 
LVL 38

Expert Comment

by:Shift-3
Comment Utility
To suppress both output and errors without creating a log file, append the following to each command:
> NUL 2>&1

Yes, you need to use it for each command whose output you want to hide.

See here for more information on redirection:
http://www.ss64.com/ntsyntax/redirection.html
0
 
LVL 26

Expert Comment

by:farhankazi
Comment Utility
You can use DOS redirector with NUL keyword (or you can use file name to save output in it) to hide displaying any message on screen (with the end of every command that show output on screen)

Like:

CommandHere >NUL
:: Above >NUL statement will hide output of if command executes successfully.

CommandHere 2>NUL
:: Above 2>NUL statement will hide error message of if command fails

CommandHere 2>NUL >NUL
:: Above 2>NUL >NUL statement will hides both successful or error message.

Hope this helps!
Farhan
0
 

Author Comment

by:NCHCIT
Comment Utility
Thank you all!  This is great information.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now