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-12 21:22
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How to hide the DOS window View 5,285 Replies 20
Original Poster Posted 2008-11-26 11:27 ·  中国 江苏 南京 电信
新手上路
Credits 6
Posts 20
Joined 2008-11-25 16:08
17-year member
UID 132064
Gender Male
Status Offline
Hello everyone, I'm running into a problem now and still haven't been able to solve it, so I had no choice but to post here for help. I hope you can help me out.
Here's the situation. For example, I wrote a batch file like this:



@echo off
call ..\set.bat

start a.exe




Here, set.bat is used to set environment variables, and a.exe needs those environment variables to be set before it can run. My problem is that when I run this bat file, a DOS window flashes by while set.bat is setting the environment variables.
I've already looked through other posts in the forum. I don't want to use vbs, and I also don't want to rely on third-party software and make it so troublesome. I don't know whether there is any other way. set.bat is used to set environment variables, so I don't know whether there is some other way to set environment variables in the background, or hide that DOS window that flashes by, or minimize the DOS window. In short, as long as it doesn't feel like the DOS window exists, that's fine. Does anyone have a good solution?

As for the call line, I tried start /min. It did minimize it, but it didn't exit automatically, and the environment variables it set actually had no effect on a.exe, which is really depressing.
I wonder whether any experts here have a good trick for this.
Thanks in advance.

[ Last edited by crystal0808 on 2008-11-26 at 11:29 ]
Floor 2 Posted 2008-11-26 12:15 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
I think it should be start a.exe that's flashing out. Try start /b a.exe

[ Last edited by tireless on 2008-11-26 at 12:53 ]
Floor 3 Posted 2008-11-26 14:00 ·  中国 江苏 南京 电信
新手上路
Credits 6
Posts 20
Joined 2008-11-25 16:08
17-year member
UID 132064
Gender Male
Status Offline
Originally posted by tireless at 2008-11-26 12:15:
I think it should be start a.exe that's flashing out. Try start /b a.exe

[ Last edited by tireless on 2008-11-26 at 12:53 ]

It's not start a.exe that's flashing out. I added a pause inside set.bat, and found that the flashing window is set.bat's. After start a.exe opens, it has an interface, so it doesn't flash
Floor 4 Posted 2008-11-26 14:02 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Can you post the contents of set.bat so we can take a look?
Floor 5 Posted 2008-11-26 18:06 ·  中国 江苏 南京 电信
新手上路
Credits 6
Posts 20
Joined 2008-11-25 16:08
17-year member
UID 132064
Gender Male
Status Offline
Originally posted by HAT at 2008-11-26 14:02:
Can you post the contents of set.bat so we can take a look?

There's really nothing much in it.
It's just setting environment variables.
For example:


@echo off
set JAVA_HOME=C:\JAVA


It's just a single line setting an environment variable, so it flashes by very quickly
Floor 6 Posted 2008-11-26 18:18 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Floor 7 Posted 2008-11-26 18:39 ·  中国 江苏 南京 电信
新手上路
Credits 6
Posts 20
Joined 2008-11-25 16:08
17-year member
UID 132064
Gender Male
Status Offline
Originally posted by HAT at 2008-11-26 18:18:
@echo off
wmic ENVIRONMENT create name="JAVA_HOME",username="<system>",VariableValue="C:\JAVA"
start a.exe

Would it work if I call another bat file? Because set.bat may be called by multiple files, and it may also be modified later. If it's like this every time, maintenance is a bit troublesome.
Thanks ^_^
Floor 8 Posted 2008-11-26 18:50 ·  中国 江苏 南京 电信
新手上路
Credits 6
Posts 20
Joined 2008-11-25 16:08
17-year member
UID 132064
Gender Male
Status Offline
Originally posted by HAT at 2008-11-26 18:18:
@echo off
wmic ENVIRONMENT create name="JAVA_HOME",username="<system>",VariableValue="C:\JAVA"
start a.exe

The window still exists, so maybe it's this bat file itself. And there's another problem: if wmic is used and the user doesn't have it installed, a window will pop up to install it. Also, after the user runs this command for the first time and the environment variable is set, a.exe still can't be used at all. Maybe it's because the environment variables haven't been refreshed.
Anyway, it still hasn't achieved the expected effect
Floor 9 Posted 2008-11-26 20:37 ·  中国 江苏 南京 电信
新手上路
Credits 6
Posts 20
Joined 2008-11-25 16:08
17-year member
UID 132064
Gender Male
Status Offline
I feel that the flashing window is the first bat file's, not the set.bat being called, so now the issue is how to add a command or parameter in a shortcut command so that when this file is opened, the DOS window doesn't flash or is minimized.
Under the interface we can choose it manually, but is there some command that can set it?
Floor 10 Posted 2008-11-26 20:40 ·  中国 重庆 电信
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
10 ideas for running batch files hidden
http://www.cn-dos.net/forum/viewthread.php?tid=23846
Floor 11 Posted 2008-11-26 20:48 ·  中国 江苏 南京 电信
新手上路
Credits 6
Posts 20
Joined 2008-11-25 16:08
17-year member
UID 132064
Gender Male
Status Offline
Originally posted by HAT at 2008-11-26 20:40:
10 ideas for running batch files hidden
http://www.cn-dos.net/forum/viewthread.php?tid=23846

I've read that already. It doesn't seem very practical. I can't use those; above I already said to keep extra stuff to a minimum
Floor 12 Posted 2008-12-28 10:08 ·  中国 河南 鹤壁 联通
新手上路
Credits 8
Posts 6
Joined 2008-12-11 12:10
17-year member
UID 133521
Gender Male
Status Offline
Yeah, how can this be done with DOS commands?

Making it into a service would also be fine
Floor 13 Posted 2009-01-14 16:48 ·  IANA 局域网IP(Private-Use)
新手上路
Credits 8
Posts 4
Joined 2009-01-08 15:14
17-year member
UID 136123
Gender Male
Status Offline
Does your set.bat pop up a window? I ran it and didn't get the behavior you described...
Floor 14 Posted 2009-01-14 17:59 ·  中国 山东 济南 槐荫区 联通
高级用户
★★★
Credits 959
Posts 474
Joined 2007-10-25 10:40
18-year member
UID 100716
Gender Male
Status Offline
This topic has already been discussed who knows how many times on our forum. It's impossible to hide it. You can only use a BAT-to-EXE program, or use VBS association
Floor 15 Posted 2009-05-07 10:02 ·  中国 广东 东莞 电信
新手上路
Credits 9
Posts 10
Joined 2009-04-16 07:38
17-year member
UID 143070
Gender Male
Status Offline
I want to know too
Forum Jump: