这是一个简单的问题...

      这是一个简单的问题...

我有这个批处理文件脚本。
它运行同一程序的多个实例,但设置略有不同。
顺便说一下,该程序不是记事本,参数也不是那些,它只是为了让它更清楚。

timeout /t 0
start cmd /k "title My Title 1 & cd C:\Windows && C: & notepad -noforcemparms & echo note1"
timeout /t 5
start cmd /k "title My Title 2 & cd C:\Windows && C: & notepad -noforcemaccel & echo note2"
timeout /t 5
start cmd /k "title My Title 3 & cd C:\Windows && C: & notepad -noforcemspd -noforcemaccel & echo note3"

问题是窗口的标题变成了“我的标题 1 - 记事本 -noforcemparms”
我预期的窗口只是“我的标题 1”

我需要批量处理的原因是:
我在 powershell 中拥有这个,它可以正确更改标题,但由于某些策略,我无法在需要运行它的机器上运行 ps 脚本。所以我不得不将它们转换为批处理。

是否可以批量更改标题?

答案1

这对我有用:

start "My Title 3" cmd /k cd /d C:\Windows & notepad -noforcemparms & echo note3

这里的命令notepad没有意义,但我认为它只是为了说明。

答案2

      这是一个简单的问题...

           是否可以批量更改标题?

           - 答案是



从命令提示符启动时更改应用程序的标题
笔记:链接到
StackOverflow
您需要编写一个程序来执行此操作。

您需要调用 Windows 的 API。这就是如何制作标题栏更改程序。

使用记事本创建一个文件并将其命名为 SetText.bas。将其存储在您的桌面上。

‍ 将其 粘贴

Imports System
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
‍    
Public Module MyApplication  
‍
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
‍   
Sub Main()
  On Error Resume Next
  Dim CmdLine As String
  Dim Ret as Long
  Dim A() as String
  Dim hwindows as long
  ‍ 
  CmdLine = Command()
  If Left(CmdLine, 2) = "/?" Then
     MsgBox("Usage:" & vbCrLf & vbCrLf & "ChangeTitleBar Oldname NewName")
  Else
     A = Split(CmdLine, Chr(34), -1, vbBinaryCompare)
     hwindows = FindWindow(vbNullString, A(1))
     Ret = SetWindowText(hwindows, A(3))    
  End If
   ̹
End Sub
End Module

然后在命令提示符窗口中输入。

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:winexe /out:"%userprofile%\desktop\SetText.exe" "%userprofile%\desktop\settext.bas" /verbose

您的桌面上已创建一个名为 settext.exe 的程序。要使用

"%userprofile%\desktop\settext" "Untitled - Notepad" "A Renamed Notepad"

相关内容