Solved

Hiding Output in Batch File Script

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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

14 Experts available now in Live!

Get 1:1 Help Now