Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


January 09, 2000

How do I automate a response when I enter a command that asks for input?

RSS
Subscribe to Windows IT Pro | See More Systems Administration Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

A. Most commands have a switch to confirm an action. For commands that require a response (e.g., a logon that asks you to enter a password), try the following command.

echo <password> | logon savillj

This command runs the command logon savillj. When the logon command asks for a password, the echo command echos the password with a return, thus entering your password.

You can also use the following code to echo a return.

echo.|cmd.exe

End of Article



Reader Comments
I am looking to do something similar, but would like to
replace <password> with a password from a text file, does anyone know how to "insert" this into the command line for
a batch program?

Corey Niemann February 12, 2001


You can also make a plain text file with your password and a "Carriage Return" (like press enter after the text).
then you can change the program's input for that instance with this:
logon savillj < filename.txt
This will use the file's contents instead of the keyboard as usual. this method works well with the commands that need more than one line of input, too.

Michael Smith July 18, 2003


I have tried the command
echo nov2008#| runas /profile /user:IN\pankajp cmd
But this is giving me the error

C:\Documents and Settings\pankajp\Desktop>echo nov2008# | runas /profile /user:
IN\pankajp cmd
Enter the password for IN\pankajp:
Attempting to start cmd as user "IN\pankajp" ...
RUNAS ERROR: Unable to run - cmd
1326: Logon failure: unknown user name or bad password.

Also I have tried the > file.txt but it is not working....
Could you please help me with this??


Thanks

pankajpimple October 24, 2008 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

How can I stop and start services from the command line?

...

Microsoft Touts Xbox 360 'Black Friday' Success

Microsoft this week revealed that its Xbox 360 video game console outsold its Sony PlayStation 3 rival 3-to-1 on "Black Friday," which curiously describes the three day weekend after Thanksgiving, a period that unofficially kicks off the holiday selling ...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events SQL Server 2008 – Can You Wait? | Philadelphia

SQL Server 2008 – Can You Wait? | Atlanta

SQL Server 2008 – Can You Wait? | Chicago

Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing