Solved

Hiding Output in Batch File Script

Posted on 2007-11-30
5
6,542 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
ID: 20383989
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
ID: 20384070
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
ID: 20384086
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
ID: 20384103
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
ID: 20384444
Thank you all!  This is great information.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 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