Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
719 views
in Technique[技术] by (71.8m points)

cmd - Create a batch file to run an .exe with an additional parameter

I need a batch file which will do the following:

1. Open CMD and navigate to a location C:/Users/...../program.exe
2. Run the program.exe with an additional command to point it to a config file:
e.g. "program.exe C:/Users/..../configFile.bgi"

How can I do this?

I tried this but with no luck:

start "C:UsersBenDesktopBGInfoginfo.exe C:UsersBenDesktopBGInfodc_bginfo.bgi"
pause

Update

I've used the solution provided by Ganesh (below) and came up with this:

cd C:UsersBenDesktopBGInfo
bginfo.exe C:UsersBenDesktopBGInfodc_bginfo.bgi

I've tested it on a local machine (changing the directories) but on the server (with the directory above) it does not work...

The folder directory with batch file: enter image description here

The error enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

in batch file abc.bat

cd c:useren_dchostdocuments
executible.exe -flag1 -flag2 -flag3 

I am assuming that your executible.exe is present in c:useren_dchostdocuments I am also assuming that the parameters it takes are -flag1 -flag2 -flag3

Edited:

For the command you say you want to execute, do:

cd C:UsersBenDesktopBGInfo
bginfo.exe dc_bginfo.bgi
pause

Hope this helps


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...