中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-09-29 11:01
47,813 topics / 349,918 posts / today 0 new / 48,278 members
DOS批处理 & 脚本技术(批处理室) » How to disable the close button of the CMD window
Printable Version  8,355 / 16
Floor1 uiopuiop Posted 2008-09-14 14:14
中级用户 Posts 211 Credits 400
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 ]
Floor2 uiopuiop Posted 2008-09-14 14:37
中级用户 Posts 211 Credits 400
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)
Floor3 tireless Posted 2008-09-14 17:17
银牌会员 Posts 1,122 Credits 2,025
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 ]
Floor4 banalo Posted 2008-09-14 17:24
新手上路 Posts 5 Credits 10
Just hide it.
Floor5 uiopuiop Posted 2008-09-14 18:03
中级用户 Posts 211 Credits 400
Floor6 tireless Posted 2008-09-14 18:24
银牌会员 Posts 1,122 Credits 2,025
I also noticed that other windows don't have this problem. Although it's not grayed out, it still can't be closed.
Floor7 uiopuiop Posted 2008-09-14 18:36
中级用户 Posts 211 Credits 400
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 ]
Floor8 tireless Posted 2008-09-14 18:41
银牌会员 Posts 1,122 Credits 2,025
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.
Floor9 uiopuiop Posted 2008-09-14 18:45
中级用户 Posts 211 Credits 400
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!
Floor10 tireless Posted 2008-09-14 18:49
银牌会员 Posts 1,122 Credits 2,025
http://good.gd/26056.htm

Caring about file size, or afraid that adding an icon will affect execution efficiency?
Floor11 uiopuiop Posted 2008-09-14 18:52
中级用户 Posts 211 Credits 400
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 ]
Floor12 tireless Posted 2008-09-14 18:58
银牌会员 Posts 1,122 Credits 2,025
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.
Floor13 uiopuiop Posted 2008-09-14 19:25
中级用户 Posts 211 Credits 400
You've worked hard :) Haha. I only knew AUTOIT before, and now I'm learning something new.
Floor14 yangjunxx Posted 2009-11-15 21:05
新手上路 Posts 5 Credits 7
Good stuff, collecting it!!!
Floor15 soyoung Posted 2010-12-24 15:19
新手上路 Posts 2 Credits 2
Good stuff, let's first study how to use it.
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023