# Batch or vbs script to start a programme minimized?



## martinlest (Nov 11, 2010)

I have been trying to get a .bat script to start a programme after a certain delay after boot. That's no problem, but the programme itself opens in a normal window. I would like the programme that starts to open only in the system tray/notification area, or whatever it is called nowadays. As it is, I have to click on the upper-right red cross to get the programme to do this - a minor inconvenience I know, but still..

Is this possible? I tried a /min switch in my .bat file, to no effect.


```
Start /min ""  "C:\Program Files (x86)\Internet Download Manager\IDMan.exe"
```
Thanks!


----------



## draceplace (Jun 8, 2001)

The Run command in vbscript shows to have a minimize paramenter. MS Run command page

An example might be...
set s = createobject("WScript.Shell")
s.run "notepad", 2

From some old class notes, I suspect you could replace NormalWindow with a 2

```
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" &  strComputer & _
    "\root\cimv2:Win32_Process")

    Set objConfig = objStartup.SpawnInstance_
    objConfig.ShowWindow = NormalWindow

    Set objProcess = GetObject("winmgmts:root\cimv2:Win32_Process")
    errReturn = objProcess.Create("calc", null, objConfig, intProcessID)
```


----------



## martinlest (Nov 11, 2010)

Thanks for the reply. Your first example, with Notepad, works of course. However:
1. How do I enter the exe file of an application in, say, the Program Files folder? Anything I have tried comes up with an error 'Can't find the file specified'. It's there, but my syntax must be wrong
2. I really need the application to 'close' (minimise) to the system tray, not the task bar. I guess no such function is possible via a simple script and I'll have to do it manually?


----------



## draceplace (Jun 8, 2001)

I think its doable but beyond my knowledge. May need to be part of the install packager or something.

Found this at Stack Overflow which might work for you.


----------

