我有一个.bat
文件,想禁用快速编辑模式对于这个单个文件:
- 当我运行脚本并单击窗口图标时,我可以转到属性,标题显示:
C:\Windows\system32\cmd.exe
特性。很明显,这将全局改变的选项cmd.exe
,因此所有批处理文件都会受到影响。
我确信可以为单个.bat
文件设置,但我在 Windows 10 中找不到它。
编辑:
最好的解决方案是使用快捷方式(参见注释)。
答案1
假设您有批处理C:\scripts\sample.cmd
,那么您可以按如下方式运行它start
,并为新控制台提供标题no-quick-edit
。
Cmd /c Start "no-quick-edit" "C:\scripts\sample.cmd"
请注意,如果从其他批处理或 cmd 控制台运行它,可能会更简单
Start "no-quick-edit" "C:\scripts\sample.cmd"
此后,您可以更改该精确标题的控制台属性。
答案2
如果这是关于标题,不需要复杂化,只需添加你的球棒:
title <nul && title your text
无标题:
Title <nul
观察:这也会删除/覆盖以下任何标题:
start "title" "file.bat"
cmd /c Start "title" "file.bat"
答案3
QuickEditOff.exe 和 QuickEditOn.exe。
将以下三个文件复制到一个文件夹中,然后双击批处理文件。它将生成一个程序 QuickEditOff.exe。
如果您想要程序将其打开,请将 135 更改为 199。
当我读到你的帖子时,我正在写一个更大的版本。所以我删除了其中的所有其他行和硬编码值。当程序变得更加用户友好时,我会更新这篇文章。我还有一系列其他控制台实用程序可以在这里编译https://winsourcecode.blogspot.com/search/label/console。
REM QuickEditOff.bat
REM This file compiles QuickEditOff.vb to QuickEditOff.exe
REM This file compiles QuickEditOn.vb to QuickEditOn.exe
REM QuickEditOff.exe turns off Quick Edit mode in the command prompt.
REM QuickEditOn.exe turns on Quick Edit mode in the command prompt.
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:exe /out:"%~dp0\QuickEditOff.exe" "%~dp0\QuickEditOff.vb"
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:exe /out:"%~dp0\QuickEditOn.exe" "%~dp0\QuickEditOn.vb"
pause
'
QuickEditOff.vb
Imports System
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Public Module MyApplication
Public Declare Function GetStdHandle Lib "kernel32" Alias "GetStdHandle" (ByVal nStdHandle As Long) As Long
Public Declare Function GetConsoleMode Lib "kernel32" (ByVal hConsoleHandle As IntPtr, ByRef lpMode As Integer) As Integer
Public Declare Function SetConsoleMode Lib "kernel32" (ByVal hConsoleHandle As Long, ByVal dwMode As Integer) As Integer
Public Const STD_ERROR_HANDLE = -12&
Public Const STD_INPUT_HANDLE = -10&
Public Const STD_OUTPUT_HANDLE = -11&
'Input
Public Const ENABLE_EXTENDED_FLAGS = &h0080
Public Const ENABLE_ECHO_INPUT = &h0004
Public Const ENABLE_INSERT_MODE = &h0020
Public Const ENABLE_LINE_INPUT = &h0002
Public Const ENABLE_MOUSE_INPUT = &h0010
Public Const ENABLE_PROCESSED_INPUT = &h0001
Public Const ENABLE_QUICK_EDIT_MODE = &h0040
Public Const ENABLE_WINDOW_INPUT = &h0008
Public Const ENABLE_VIRTUAL_TERMINAL_INPUT = &h0200
'Output
Public Const ENABLE_PROCESSED_OUTPUT = &h0001
Public Const ENABLE_WRAP_AT_EOL_OUTPUT = &h0002
Public Const ENABLE_VIRTUAL_TERMINAL_PROCESSING = &h0004
Public Const DISABLE_NEWLINE_AUTO_RETURN = &h0008
Public Const ENABLE_LVB_GRID_WORLDWIDE = &h0010
Sub Main()
Dim hIn as IntPtr
Dim Ret as Integer
hIn = GetStdHandle(STD_INPUT_HANDLE)
Ret = SetConsoleMode(hIn, 135)
If Ret = 0 then Console.WriteLine(Hex(Ret) & " - " & err.lastdllerror)
End Sub
End Module
'QuickEditOn.vb
Imports System
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Public Module MyApplication
Public Declare Function GetStdHandle Lib "kernel32" Alias "GetStdHandle" (ByVal nStdHandle As Long) As Long
Public Declare Function GetConsoleMode Lib "kernel32" (ByVal hConsoleHandle As IntPtr, ByRef lpMode As Integer) As Integer
Public Declare Function SetConsoleMode Lib "kernel32" (ByVal hConsoleHandle As Long, ByVal dwMode As Integer) As Integer
Public Const STD_ERROR_HANDLE = -12&
Public Const STD_INPUT_HANDLE = -10&
Public Const STD_OUTPUT_HANDLE = -11&
'Input
Public Const ENABLE_EXTENDED_FLAGS = &h0080
Public Const ENABLE_ECHO_INPUT = &h0004
Public Const ENABLE_INSERT_MODE = &h0020
Public Const ENABLE_LINE_INPUT = &h0002
Public Const ENABLE_MOUSE_INPUT = &h0010
Public Const ENABLE_PROCESSED_INPUT = &h0001
Public Const ENABLE_QUICK_EDIT_MODE = &h0040
Public Const ENABLE_WINDOW_INPUT = &h0008
Public Const ENABLE_VIRTUAL_TERMINAL_INPUT = &h0200
'Output
Public Const ENABLE_PROCESSED_OUTPUT = &h0001
Public Const ENABLE_WRAP_AT_EOL_OUTPUT = &h0002
Public Const ENABLE_VIRTUAL_TERMINAL_PROCESSING = &h0004
Public Const DISABLE_NEWLINE_AUTO_RETURN = &h0008
Public Const ENABLE_LVB_GRID_WORLDWIDE = &h0010
Sub Main()
Dim hIn as IntPtr
Dim Ret as Integer
hIn = GetStdHandle(STD_INPUT_HANDLE)
Ret = SetConsoleMode(hIn, 199)
If Ret = 0 then Console.WriteLine(Hex(Ret) & " - " & err.lastdllerror)
End Sub
End Module