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-08-01 23:16
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to use a batch file to open a program View 1,504 Replies 7
Original Poster Posted 2006-07-18 18:06 ·  中国 四川 成都 电信
新手上路
Credits 10
Posts 3
Joined 2006-05-30 07:54
20-year member
UID 56232
Status Offline
How to use a batch file to open a program
For example, open QQ
@echo off
"C:\Program Files\QQ2005\QQ.exe"
exit
After I write it like this, that CMD thing shows up.
If after running it, I don't want that CMD thing to show,
please help me out, thanks
Floor 2 Posted 2006-07-18 18:25 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
  Your problem is actually how to hide the CMD window, not how to open a program. Please pay attention to the change in the thread title.

  You can't hide the CMD window just by writing bat code alone; you can only do it with the help of other software. Go to HanHua New Century and download QuickBFC to play with.
Floor 3 Posted 2006-07-18 18:38 ·  中国 四川 成都 电信
新手上路
Credits 10
Posts 3
Joined 2006-05-30 07:54
20-year member
UID 56232
Status Offline
The poster above, I followed your method and downloaded that QBFC, but it still can't get rid of that CMD thing. Someone help me out,
Floor 4 Posted 2006-07-18 18:53 ·  中国 四川 成都 电信
新手上路
Credits 10
Posts 3
Joined 2006-05-30 07:54
20-year member
UID 56232
Status Offline
I solved it too
@echo off
start D:\Real\Real.exe
goto end
:end

It's only after start that if there are spaces in the path, then there will be a problem!
Floor 5 Posted 2006-07-18 21:07 ·  中国 四川 成都 鹏博士宽带
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
  Sigh, I thought you wanted to hide the CMD window while running CMD, but it turns out it was that CMD couldn't close automatically. “After I write it like this, that CMD thing shows up. If after running it, I don't want that CMD thing to show” — just look at how you said it. Speechless.

  Also: I keep noticing that some people like to use "如果". Could it be that "如果" = “如何”?

  Using start "program title" "path with spaces" will solve the problem with spaces.
Floor 6 Posted 2006-07-19 01:32 ·  中国 山东 青岛 联通
中级用户
★★
Credits 232
Posts 53
Joined 2005-08-24 07:03
20-year member
UID 41889
Gender Male
From 中国
Status Offline
Spaces in filenames? I do know that if it's a directory like c:\program files, it can be written as c:\progra~1. If there is also C:\program files2, it can be written as c:\progra~2.
But if the directory name is something like c:\abc def, then I don't know. If anyone has figured it out, say something?
Floor 7 Posted 2006-07-19 16:36 ·  中国 山西 运城 电信
中级用户
★★
Credits 241
Posts 131
Joined 2005-09-28 19:01
20-year member
UID 42920
Gender Male
Status Offline
@echo off

set /p yy=Please enter the program you want to find (you need to include the extension):
dir /s/b %yy% >ok.txt
set /p uu=<ok.txt
start %uu%
del ok.txt
goto :end

:end
exit
房东说:这娃是个好孩子!
Floor 8 Posted 2006-07-19 16:38 ·  中国 山西 运城 电信
中级用户
★★
Credits 241
Posts 131
Joined 2005-09-28 19:01
20-year member
UID 42920
Gender Male
Status Offline
This one searches for it and runs it automatically, and it can also exit CMD after running the program...
PS: Whatever drive this .bat is on, it can only search programs on that drive!
房东说:这娃是个好孩子!
Forum Jump: