Solved

Hiding Output in Batch File Script

Posted on 2007-11-30
5
6,552 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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