China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-20 08:03
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to automatically close the command line window View 15,875 Replies 40
Floor 16 Posted 2006-07-21 09:06 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
19-year member
UID 57801
Gender Male
Status Offline
I want to use a batch script to call a program Adobe Reader 7.0, which is a software for viewing PDF documents, and I believe many people use it. The path is "D:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe". Now I want to use a batch file to start this program and then have the batch window close automatically while Adobe Reader 7.0 is still running. I can only start this program with the batch, but the window can't close automatically. As long as the program is running, the command line window is still there. Who can achieve the function of closing the command line window automatically after starting this program? Note: Please speak after testing... Thank you...
Floor 17 Posted 2006-07-21 10:27 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
The person upstairs, post your code and then we'll talk.
Floor 18 Posted 2006-07-21 10:37 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
19-year member
UID 57801
Gender Male
Status Offline
=======

@echo off
"D:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe"
exit

=======
Only in this way can a program be started in a batch file. Other methods such as START or without quotes don't work. Please namejm give advice... Thanks...
Floor 19 Posted 2006-07-21 10:38 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
19-year member
UID 57801
Gender Male
Status Offline
Statement... For some reason, it's better not to use methods like cd /d or pushd popd to switch the current directory.
Floor 20 Posted 2006-07-21 11:30 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
First set the search path for executable files and then start.

%ProgramFiles% = Program Files directory of the system drive

@echo off
path=%path%;%ProgramFiles%\Adobe\Acrobat 6.0\Reader\
start AcroRd32.exe
exit


[ Last edited by zxcv on 2006-7-21 at 13:11 ]
Floor 21 Posted 2006-07-21 12:57 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
19-year member
UID 57801
Gender Male
Status Offline
The solution on floor 20 is quite OK, heh heh...
By the way, I timidly ask a question: Does this PATH - set path only work for one line of the start statement? Because I added a line start ABC.exe below start AcroRd32.exe, and it also ran. That is to say, the PATH - set path won't affect the second and following statements from the first START?
thanks

[ Last edited by flying008 on 2006 - 7 - 21 at 13:01 ]
Floor 22 Posted 2006-07-21 13:11 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
won't

path only indicates that the files to be executed can be searched within this path

Changing it will not affect the system's default set path

path=%path%;%ProgramFiles%\Adobe\Acrobat 6.0\Reader\

Otherwise, the software in the original default set path of the system may not be executable

[ Last edited by zxcv on 2006-7-21 at 13:14 ]
Floor 23 Posted 2006-07-21 13:33 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
In the sentence "path=%path%;%ProgramFiles%\Adobe\Acrobat 6.0\Reader\", the %path% is used to retain the original default search path, so it has no impact on directly running ABC.exe. If you remove %path%, then you have to honestly add the absolute path of ABC.exe.

In addition to using the method of setting the search path, you can also run it directly using the start command, but it needs to be slightly modified because the path of AcroRd32.exe contains a space symbol: start "Title of AcroRd32.exe program" "Path of AcroRd32.exe"

[ Last edited by namejm on 2006-7-21 at 13:34 ]
Floor 24 Posted 2006-07-21 13:57 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
19-year member
UID 57801
Gender Male
Status Offline
Hello……namejm
But this program AcroRd32.exe uses the following statement
@echo
start "D:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe"
exit
It just can't start. I've tried the START with quotes many times.
Floor 25 Posted 2006-07-21 14:05 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
You need to use start "Title of AcroRd32.exe" "D:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe". Did you write it correctly?
Floor 26 Posted 2006-07-21 14:10 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Tried according to namejm's idea:
@echo off
start "" "%ProgramFiles%\Adobe\Acrobat 7.0\Reader\AcroRd32.exe"
exit

It's also okay. The first "" is the start title quote, and you can not write content
Floor 27 Posted 2006-07-21 14:16 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
You can ignore the path for the installed software.
@echo off
start AcroRd32
exit
That's it.
Floor 28 Posted 2006-07-21 15:30 ·  中国 湖北 武汉 电信
中级用户
★★
Credits 245
Posts 103
Joined 2006-06-30 00:00
19-year member
UID 57801
Gender Male
Status Offline
Originally posted by namejm at 2006-7-21 14:05:
You need to use start "Title of AcroRd32.exe" "D:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe", did you write it correctly?
Why must it be ]"Title of AcroRd32.exe"? I just didn't write this.
Floor 29 Posted 2006-07-21 15:33 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
“Ignore the path for the installed software”? Fastslz, are you kidding? Anyway, I put the bat file on the desktop and then start to install a program in another partition, and it never succeeded.

Re zxcv:
  
  Hehe, I didn't expect that the format of start "" "program path" can also work. Thanks for the reminder, I've learned something new again : )
Floor 30 Posted 2006-07-21 15:46 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Originally posted by fastslz at 2006-7-21 14:16:
For installed software, you can ignore the path
@echo off
start AcroRd32
exit
That's it


KAO, it's really
But it only works for a part of the software that is correctly installed and registered in the registry. I tried it, and it works for normally installed ones and AutoCAD.

Originally posted by namejm at 2006-7-21 15:33:
  Re zxcv:
  
  Hehe, I didn't expect that the format of start "" "program path" can also work. Thanks for the reminder, I've learned something new again :)

Actually, it also defines the title, but the title is just empty
Forum Jump: