Computing.Net > Forums > Programming > pass parameter to batch script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

pass parameter to batch script

Reply to Message Icon

Name: newtechie
Date: December 12, 2007 at 14:24:44 Pacific
OS: win server 2003
CPU/Ram: p3
Product: dell
Comment:

i'm writing a script that needs to call another script called "backup.bat". when backup.bat is invoked, it asks for a password which I want to hardcode in my script so I can run it in background without invoking the user.

how can I do this?



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: December 12, 2007 at 14:53:39 Pacific
Reply:

Post the code for the 2 scripts.

"Computer security." — Oxymoron


0

Response Number 2
Name: newtechie
Date: December 12, 2007 at 15:16:40 Pacific
Reply:

wrapper script:
cd "C:\Program Files\Product group\Product name"

backupAllData.bat -backup

original script output:

Dec 12, 2007 3:14:19 PM com.product.BackupTool main
INFO: args[0]=-backup

Enter the user's password: ********

this is the point where the user is supposed to enter the password - i want to hardcode this part

backupAllData.bat is just invoking a java classfile and i dont have access to the code, only the class file and the script invoking the classfile
I've modified product names/titles for security purposes


0

Response Number 3
Name: tonysathre
Date: December 13, 2007 at 05:05:16 Pacific
Reply:

If the program doesn't have a switch to allow you to script it, I don't think you could do it with built-in commands. You could probably use expect.exe to accomplish what you need.

If you have trouble learning the syntax of expect, try autoexpect.exe which records what you do, in your case inputting a password and such, and saves it in an expect script. You will have to specify the UNC path to the exe on a server in your batch script: \\server\share\expect.exe [params]

Unless you push out the exe to your clients with a GPO.

"Computer security." — Oxymoron


0

Response Number 4
Name: Razor2.3
Date: December 13, 2007 at 11:42:49 Pacific
Reply:

(echo 3
echo 1
echo 2) | sort

I'm not saying this method would work, but it's probably your best chance.

0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Wireless computing Delete dupe filename igno...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: pass parameter to batch script

passin g parameter to batch file www.computing.net/answers/programming/passin-g-parameter-to-batch-file-/15909.html

Passing parameter to exe file www.computing.net/answers/programming/passing-parameter-to-exe-file/4717.html

batch to read a typed filename and www.computing.net/answers/programming/batch-to-read-a-typed-filename-and-/9196.html