使用 vbscript 更改控制台标题
有没有办法改变cmd标题?我写了一个vbs程序。但dos标题很糟糕。
名称为 c:\windows\system32\cscript.exe 我尝试使用:
title the_name 和 title =“name”
但这两个都不起作用。
感谢您的帮助。
is there a way to change the cmd title? I wrote a vbs program. But the dos title is bad.
The name ist c:\windows\system32\cscript.exe
I try it with:
title the_name and
title ="name"
But both doesn't works.
Thanks for help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
@AlexK您指向的链接实际上显示了如何更改命令窗口的标题,所以我不确定为什么这不能解决马蒂亚斯的问题。
@Matthias - 因为您已经在使用 cscript,所以您有几个选择:
或者只是让父脚本执行一个子脚本,但在运行之前提示输入标题cscript 命令如下所示:
查看 IEUnit 项目,特别是 Win32Dom activex 对象。这是一个很好的起点,因为它解决了您对此选项可能遇到的“如何创建 ac# activex 对象”和“如何调用 win32 api”问题。它已经为您完成了 findWindow 部分。
http://code.google.com/p/ ieunit/source/browse/#svn%2Ftrunk%2Ftool%2FWin32Dom
@AlexK The link you point to actually shows how you CAN change the title of the command window so I'm not sure why that doesn't work as a solution to Matthias's problem.
@Matthias - since you are already using cscript you have a couple of options:
or just make the parent script execute one child script but prompt for the title before it runs the cscript command like so:
Check out the IEUnit project, specifically the Win32Dom activex object. It's a good project to start from because it solves the "how to create a c# activex object" and "how to call the win32 api" questions you might have for this option. And it already has the findWindow portion finsihed for you.
http://code.google.com/p/ieunit/source/browse/#svn%2Ftrunk%2Ftool%2FWin32Dom
不幸的是你无法使用任何 WSH 对象从脚本内执行此操作。
唯一的方法是通过中介启动脚本(使用 TITLE 命令的 .bat 或使用 %comspec% 参数的另一个脚本)。
Unfortunately you cannot do that from within the script using any of the WSH objects.
The only way to do it is to launch the script via an intermediary (a .bat using the TITLE command or another script using a %comspec% argument).
您是否需要在代码中更改它,或者您只是想让它看起来更好一点?您可以通过创建脚本的快捷方式,然后更改快捷方式的名称(在快捷方式的属性中,更改为
常规
选项卡并更改那里的名称)来完成此操作。Do you need to change it in the code or do you just want it to look a little nicer? You could possibly do it by creating a shortcut to your script and then changing the name of the shortcut (in the properties of the shortcut, change to the
General
tab and change the name there).