New
#11
Thanks for the advice. Actually I had it turned off for other reasons. I just turned UAC back on to the default settings and rebooted to test what would happen with Task scheduler and I am not getting any alerts which is fine. Thanks again.
Kind regards
Chris
For running the program minimized using the cmd.exe /C start /MIN, the focus of the window still changes since the first cmd.exe is launched in a real window. You can avoid this by using the vbscript with WScript.exe:
1. Create a .vbs script to the folder/name of your choice, I use startprocess.vbs in my example.
2. Create launcher for the script to run your programCode:Option ExplicitDim oShell 'WScript.Shell objectDim iOption 'WScript.shell.run visibility option'For iOption, see https://technet.microsoft.com/en-us/library/ee156605.aspxSet oShell = CreateObject("WScript.Shell")If WScript.Arguments.Count >0 Then If WScript.Arguments.Count > 1 then iOption = CLng(WScript.Arguments.Item(1)) oShell.run WScript.arguments.item(0), iOption Else oShell.run WScript.arguments.item(0) End IfEnd If
wscript.exe /B /NoLogo [path]/startprocess.vbs "your command here with parameters" 7
e.g. wscript.exe /B /NoLogo "C:\Windows\System32\cmd.exe /C MyStartup.cmd > C:\Temp\MyStartup.log" 7
Now you can place the launcher to the Windows Task Scheduler (or any other place) and your command with parameters will be run minimized without changing the focus of the windows i.e. your work is not affected by the running process. This is due to the fact that wscript.exe does not create any windows when run with the batch mode with /B option.
Script does not contain any error handling or other additional stuff.
What the script does it uses the first argument (if it exist) as a full command line for launching the command and the second parameter as WShell.exec visibility option (Microsoft Windows 2000 Scripting Guide - Running Programs)
When using with the Windows Task Schedule, you place
C:\Windows\System32\wscript.exe
as executable and the rest of the parameters as arguments, in my example
/B /NoLogo "C:\Windows\System32\cmd.exe /C MyStartup.cmd > C:\Temp\MyStartup.log" 7
There was a mistake in startup, the actual script was missing from command line:
When using with the windows Tas Scheduler, you place
C:\Windows\System32\wscript.exe
as executable and the rest of the parameters as arguments, in my example
/B /NoLogo path\startprocess.vbs "C:\Windows\System32\cmd.exe /C MyStartup.cmd" 7
In the example I initially used the redirection of stdout to a log file (> C:\Temp\Mystartup.log) which is optional of course.
I want to start a program (Zotero) minimized, so I tried the bat file approach with a single line:
start /min "C:\Program Files (x86)\Zotero\zotero.exe"
and it failed to start at all. I went to Command Prompt and tried
C:
start /min "Program Files (x86)\Zotero\zotero.exe"
and, surprise, it didn't work there either! It simply creates and minimizes another C: command prompt window (if I start without the /min, it opens the C: window). The only thing that worked was to navigate to the final directory, and then it started, minimized or not. So the final working bat file is:
C:
cd "Program Files (x86)\Zotero"
start /min zotero.exe
I tried the same sequence of tests with another program, and the same thing happened.
I'm happy with the solution, but does anyone have any idea what's going on?
Cheers!
Ed
Hello, this thread has helped me with a recent app from my mouse (Mars Gaming MM018) running on win10, the app has no startup options so i created a task to run it with high privileges and skip the yes/no UAC question.
Can you please help me out finding the argument to have it minimized to tray?
(the app close button on top corner minimizes to tray)