有没有办法将 VBScript 文件作为屏幕保护程序运行?

发布于 2024-11-17 17:07:29 字数 107 浏览 6 评论 0 原文

您可以执行 VBS 文件作为屏幕保护程序吗?我已成功将 cmd.exe 重命名为 *.scr 并且可以正常工作,但如果可能的话,我需要能够运行 VBS 文件作为屏幕保护程序。

Can you execute a VBS file as a screen saver? I have managed to rename cmd.exe to *.scr and this works, but I need to be able to run a VBS file as the screen saver if this is possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒中人 2024-11-24 17:07:29

不,这是不可能的。

在 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 to cmd.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.

朦胧时间 2024-11-24 17:07:29

您可以简单地编写一个启动 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文