在 Vista/Windows 7 中以编程方式关闭启动程序
我希望能够编写一个脚本来关闭 Windows 启动中包含的应用程序。我知道常识是为什么不将其从启动中删除,但我希望它运行,因为该应用程序连接了我的 NAS。我只是每次都关闭它,因为除了它建立连接之外,我对实际的应用程序没有任何用处。
所以我想到了一个好主意,也许我可以编写一个脚本,该脚本也将在应用程序启动后在启动时运行,从而杀死/关闭它。
首先这听起来可能吗?有更好的办法吗?
I am looking to be able to write a script that will close an application that is included in the Windows start up. I know the common sense is why not remove it from start up, but I want it to run because the application connects my NAS. I just close it every single time because I have no use for the actual app except for the fact that it makes the connections.
So I got the bright idea that perhaps I could write a script that will also run in the startup after the app is launch that will kill/close it.
First does this sound possible? Is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该应用程序是否将驱动器映射到 NAS 上的共享文件夹?如果是这样,那么您可以将其从启动文件夹中删除,并且可以:
Is the app mapping drives to shared folders on your NAS? If so, then you could remove it from the Startup folder and either:
您可以创建一个 .bat 文件并在 NAS 程序运行后在启动过程中运行它。以下代码将杀死进程的所有实例(当前代码将杀死记事本)
Dim WMI, KillProc
暗淡进程名称:进程名称 =“notepad.exe”
设置 WMI = GetObject(“winmgmts:\.\root\cimv2”)
设置 KillProc = WMI.ExecQuery("Select * from Win32_ProcessWhere Name = '" & processName & "')
对于 KillProc 中的每个过程,
过程终止()
下一个
You can create a .bat file and run it during startup, after the NAS program has run. The following code will kill all instances of a process (the current code will kill notepad)
Dim WMI, KillProc
Dim processName: processName = "notepad.exe"
Set WMI = GetObject("winmgmts:\.\root\cimv2")
Set KillProc = WMI.ExecQuery("Select * from Win32_Process Where Name = '" & processName & "')
For Each Proc In KillProc
Proc.Terminate()
Next