Justin
Justin

Reputation: 4539

Closing a startup program programmatically in Vista/Windows 7

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?

Upvotes: 0

Views: 860

Answers (2)

user463416
user463416

Reputation:

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

Upvotes: 2

Bullines
Bullines

Reputation: 5696

Is the app mapping drives to shared folders on your NAS? If so, then you could remove it from the Startup folder and either:

  • use Explorer's "Map Network Drive" feature
  • write a BAT file to run on Startup that does a NET USE to map
  • write some VBScript :), using WScript.Network.MapNetworkDrive

Upvotes: 2

Related Questions