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-07-06 17:11
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to disable the close button of the CMD window View 7,507 Replies 16
Original Poster Posted 2008-09-14 14:14 ·  中国 上海 浦东新区 电信
中级用户
★★
Credits 400
Posts 211
Joined 2007-09-30 18:02
18-year member
UID 98650
Gender Male
Status Offline
Saw a script that can gray out the close button of the CMD window to prevent someone from closing the window.

[ Last edited by uiopuiop on 2008-9-14 at 02:48 PM ]
Floor 2 Posted 2008-09-14 14:37 ·  中国 上海 浦东新区 电信
中级用户
★★
Credits 400
Posts 211
Joined 2007-09-30 18:02
18-year member
UID 98650
Gender Male
Status Offline
http://www.cn-dos.net/forum/viewthread.php?tid=39745&fpage=1&highlight=CMD%E7%AA%97%E5%8F%A3%2B%E5%85%B3%E9%97%AD%E6%8C%89%E9%92%AE

Just don't know if there are any other ways, and it can be done without using GRAY.EXE, heh heh.

@echo off
start /b gray.exe
echo This is a test
echo.
REM If you don't kill gray.exe, the pause won't work, and it can't be pushed out no matter what
taskkill /f /im gray.exe >nul
pause

GRAY must be killed at the end. After killing gray, it can exit. Otherwise, when you right-click the batch processing in the status bar, the X will appear again. The shortcoming is that grey.exe can't exit by itself (it seems there are no parameters). taskkill /f /im gray.exe will kill all gray.exe, thus affecting the windows of other applications' secondary functions.

[ Last edited by uiopuiop on 2008-9-14 at 02:55 PM ]
Attachments
gray.zip (21.54 KiB, Downloads: 170)
Floor 3 Posted 2008-09-14 17:17 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
In the 1 HOUR SOFTWARE, there is a NoClose, and helfee has modified it into a command-line version.

Usage:

Disable the window titled C:\WINDOWS:
x.exe /dC:\WINDOWS

Enable the window titled C:\WINDOWS:
x.exe /eC:\WINDOWS

Disable the window with the class name CabinetWClass:
x.exe /dahk_classCabinetWClass

If the title or class name has spaces, you must add double quotes:
x.exe "/dC:\Program Files"

Process N windows simultaneously:
x.exe /dC:\WINDOWS /eC:\WINDOWS\system32 "/dC:\Program Files" /dahk_classConsoleWindowClass

Download address: http://good.gd/26048.htm

http://upload.cn-dos.net/img/930.zip

───────────────── Moderation Records ─────────────────
Executed: HAT
Operation: Uploaded attachment for the poster on 2008-10-11
───────────────── Moderation Records ─────────────────


[ Last edited by tireless on 2008-10-12 at 17:03 ]
Recent Ratings for This Post ( 3 in total) Click for details
RaterScoreTime
uiopuiop +1 2008-09-14 17:27
uemuem +2 2008-11-01 12:41
moniuming +3 2008-12-21 21:08
Floor 4 Posted 2008-09-14 17:24 ·  中国 福建 漳州 电信
新手上路
Credits 10
Posts 5
Joined 2008-09-05 14:49
17-year member
UID 124863
Gender Male
Status Offline
Just hide it.
Floor 5 Posted 2008-09-14 18:03 ·  中国 上海 浦东新区 电信
中级用户
★★
Credits 400
Posts 211
Joined 2007-09-30 18:02
18-year member
UID 98650
Gender Male
Status Offline
Floor 6 Posted 2008-09-14 18:24 ·  中国 江西 赣州 安远县 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
I also noticed that other windows don't have this problem. Although it's not grayed out, it still can't be closed.
Floor 7 Posted 2008-09-14 18:36 ·  中国 上海 浦东新区 电信
中级用户
★★
Credits 400
Posts 211
Joined 2007-09-30 18:02
18-year member
UID 98650
Gender Male
Status Offline
Well, thanks! Great stuff!

VB has just too much code. This thing also has a shell - 203kb, and you can't even delete that ugly icon, while gray.exe is only 56kb.

[ Last edited by uiopuiop on 2008-9-14 at 06:43 PM ]
Floor 8 Posted 2008-09-14 18:41 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Originally posted by uiopuiop at 2008-9-13 10:36 PM:
That's right, thanks! Great stuff!

VB has just too much code. This thing is also packed - 203kb, gray.exe is only 56kb.

It's not packed. This is a script compiled with AutoHotkey, with the extension .ahk. If you have AutoHotkey installed on your computer, you can directly use x.ahk.

Compiling x.ahk into x.exe results in this size. After I added an icon, the size is 203 KB, and without an icon, it's 198 kb.
Floor 9 Posted 2008-09-14 18:45 ·  中国 上海 浦东新区 电信
中级用户
★★
Credits 400
Posts 211
Joined 2007-09-30 18:02
18-year member
UID 98650
Gender Male
Status Offline
Originally posted by tireless at 2008-9-14 06:41 PM:

It's not a packed shell. This is a script compiled with AutoHotkey, with the file extension .ahk. If you have AutoHotkey installed on your computer, you can just use x.ahk directly.

When you compile x.ahk into x.exe, it's just this size. After I added an icon, the size is 203 KB, and without an icon, it's 198 KB.


Can you compile an icon-free EXE and upload it? Thanks!
Floor 10 Posted 2008-09-14 18:49 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
http://good.gd/26056.htm

Caring about file size, or afraid that adding an icon will affect execution efficiency?
Floor 11 Posted 2008-09-14 18:52 ·  中国 上海 浦东新区 电信
中级用户
★★
Credits 400
Posts 211
Joined 2007-09-30 18:02
18-year member
UID 98650
Gender Male
Status Offline
I want to use it as a domain login script, the original icon is too ugly. The exe should be as small as possible, copy faster. The one you have now still has an icon with an H :^)

[ Last edited by uiopuiop on 2008-9-14 at 06:54 PM ]
Floor 12 Posted 2008-09-14 18:58 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
Originally posted by uiopuiop at 2008-9-13 10:52 PM:
Want to use it as a domain login script. The original icon is too ugly. The smaller the exe, the better, so it copies faster. Your current one still has a H icon :^)

[ Last edited by uiopuiop on 2008-9-14 at 06:54 PM ]

I took a screenshot, then used Photoshop, enlarged it and carefully cropped it into a png, and then converted it with png2ico... because I think it looks better to leave some borders.

The H icon is the one that comes with AutoHotkey. I tried using Resource Hacker to remove those icons, but it seemed to have errors.
Floor 13 Posted 2008-09-14 19:25 ·  中国 上海 浦东新区 电信
中级用户
★★
Credits 400
Posts 211
Joined 2007-09-30 18:02
18-year member
UID 98650
Gender Male
Status Offline
You've worked hard :) Haha. I only knew AUTOIT before, and now I'm learning something new.
Floor 14 Posted 2009-11-15 21:05 ·  中国 天津 联通
新手上路
Credits 7
Posts 5
Joined 2009-01-08 18:18
17-year member
UID 136150
Gender Male
Status Offline
Good stuff, collecting it!!!
Floor 15 Posted 2010-12-24 15:19 ·  中国 黑龙江 哈尔滨 联通
新手上路
Credits 2
Posts 2
Joined 2010-12-23 21:33
15-year member
UID 179747
Gender Male
Status Offline
Good stuff, let's first study how to use it.
Forum Jump: