有没有办法将 VBScript 文件作为屏幕保护程序运行?
您可以执行 VBS 文件作为屏幕保护程序吗?我已成功将 cmd.exe
重命名为 *.scr 并且可以正常工作,但如果可能的话,我需要能够运行 VBS 文件作为屏幕保护程序。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您可以执行 VBS 文件作为屏幕保护程序吗?我已成功将 cmd.exe
重命名为 *.scr 并且可以正常工作,但如果可能的话,我需要能够运行 VBS 文件作为屏幕保护程序。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
不,这是不可能的。
在 Windows 中,屏幕保护程序(*.scr 文件)是一种特殊类型的可执行 (.exe) 文件。这就是为什么将
cmd.exe
等程序重命名为cmd.scr
会导致它作为屏幕保护程序“工作”。特别是,屏幕保护程序响应某些命令行开关(或参数),这就是操作系统如何让它们执行诸如显示配置对话框或显示预览之类的操作。但是您无法将 VBScript 文件编译为可执行文件,因此无法使此技巧对它们起作用。
您也许能够将 VBScript 代码迁移到 VB 6 应用程序,然后将其编译为可执行文件并作为屏幕保护程序运行,但我无法想象这值得花费开发时间。如果您对这样的事情感兴趣(并且可以获得 VB 6 的旧副本!),您可能可以在网上找到一些操作指南,例如 这个。
但老实说,我很难想象为什么人们会想要运行 VBScript 脚本作为屏幕保护程序,或者它会在屏幕上显示什么。您对屏幕上显示的内容没有太多控制权,并且无法从 VBScript 调用本机 Windows API 函数。您最终会依赖一些外部库,因此您不妨首先使用该库。
No, this is not possible.
In Windows, screen savers (*.scr files) are a special type of executable (.exe) file. That is why renaming a program like
cmd.exe
tocmd.scr
causes it to sort of "work" as a screen saver. In particular, screen savers respond to certain command line switches (or parameters), which is how the OS gets them to do things like show the configuration dialog or display a preview.But you can't compile VBScript files into executables, so there's no way to make this trick work for them.
You might be able to migrate the VBScript code to a VB 6 application, which you could then compile into an executable and run as a screen saver, but I can't imagine that this would be worth the development time. If you're interested in such a thing (and can get your hands on an old copy of VB 6!), you can probably find several how-to guides online, like this one.
But I'm honestly having a hard time imagining why one would ever want to run a VBScript script as a screen saver, or what it would display on the screen. You don't have very much control over what gets displayed on the screen, and you can't call down to native Windows API functions from VBScript. You'd end up relying upon some external library, so you might as well just use that library in the first place.
您可以简单地编写一个启动 vb 脚本的批处理文件:
CD“%SystemRoot%\System32”
启动/等待 Wscript.exe "c:\program files\myscript.vbs"
Exit
然后将批处理编译为exe,将exe重命名为scr。
You can simply write a batch file that starts your vb script:
CD "%SystemRoot%\System32"
Start /Wait Wscript.exe "c:\program files\myscript.vbs"
Exit
Then compile the batch to exe, rename the exe to scr.