Stop taskeng.exe window from popping up

39,198

Solution 1

More specifically to Daniel R Hicks' bounty/example, but I think it can still be applied to the original problem:

If it's a batch file being launched from Task Scheduler, then instead of just launching the Batch file minimized/invisible, you probably also need to modify the batch file itself to run it's commands invisibly.

So change:

cd C:\Users\danh\bin
"C:\Program Files\Java\jre7\bin\java.exe" Signature

To something like:

cd C:\Users\danh\bin
start /b "C:\Program Files\Java\jre7\bin\java.exe" Signature

Or perhaps eliminate the batch file completely and just do everything from the (VBS) script you're launching directly from the Task Scheduler.

Something like:

Set Shell = CreateObject("WScript.Shell")
Shell.CurrentDirectory = "C:\Users\danh\bin" 
Shell.Run "C:\Program Files\Java\jre7\bin\java.exe Signature", 0, False

Solution as implemented by DanH, in response to techie007's suggestions, satisfying the bounty:

One file, named RunSignatured.vbs, containing:

Set Shell = CreateObject("WScript.Shell")
Shell.CurrentDirectory = "C:\Users\danh\bin" 
Shell.Run "java.exe Signature", 0, False

Note that the above relies on java.exe being in path, since the technique does not work with the blank in Program Files when specifying a full path. There are no doubt other ways to work around this problem, but that's for others to discover.

Then add RunSignature.vbs as the "program/script" name in the "Action" in Task Scheduler.

Solution 2

You could run the scheduled tasks as a different user, that way they will no interact with your normal account's interactive desktop at all. This certainly seems to work on the Windows2003 servers I administer. Just be careful to make sure that file permissions and other authentication details are set such that the tasks can access what they need to when un as this different user.

Edit: Or instead of running a console tool directly you could have a small script that runs it using WScript.Shell.Run with the "minimise, no focus change" option:

' sample script: c:\scripts\test.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "c:\location\of\tool\utility.exe", 7

then run this with the task scheduler (the command line being something like wscript c:\scripts\test.vbs) instead of calling the tool directly. You should be able to call batch files and other scripts that way too. There is also a "completely hide" option (replace the 7 above with a 0), though in either case the hide/minimise only controls the initial window: if the tool opens more itself then they may still steal focus as before.

See http://msdn.microsoft.com/en-us/library/d5fk67ky%28VS.85%29.aspx for a full list of options for the run method.

Solution 3

The simplest way to hide an application launched from the Task Scheduler is to set it to "Run whether user is logged on or not". This setting can be found in the General Tab of the Scheduled Task Properties.

Solution 4

Try running your scheduled task like this:

C:\Windows\System32\cmd.exe /c start /b c:\fullpath\mybackup.bat

The start /b should start the application without creating a new window.

If this does not work, then you can create an standalone AutoIt script that will hide the taskeng.exe window. AutoIt scripts can be compiled to a .exe.

The .exe would be the first line in your mybackup.bat file. The AutoIt code would look like this:

WinSetState("taskeng", @SW_HIDE)

Solution 5

Try 4trayMinimizer. You can define apps that are hidden by default.

Share:
39,198

Related videos on Youtube

Boeka
Author by

Boeka

I'm a freelance webapplication developer, currently mainly using node.js and PHP, but also experienced in VBScript ASP 2.0.

Updated on September 17, 2022

Comments

  • Boeka
    Boeka over 1 year

    I have several processes scheduled in my Windows 7 environment, mainly for backups, that are supposed to run in the background.

    However instead of just doing it's work quietly in the background, the task scheduler pops up a black (console like) "taskeng.exe" window. The window goes in front of all other windows. Luckily it doesn't steal my keyboard focus, but it blocks the view on everything.

    taskeng.exe

    Is there a way to avoid this window - or at least have it appear in the background without stealing my VISUAL focus?

    Example edited in after bounty applied:

    Here is my last attempt at using the WScript stuff (in a file named RunSignatured.bat):

    Set Shell = CreateObject("WScript.Shell")
    Shell.Run C:\Users\danh\Bin\signatured.bat, 0, False
    

    The signatured.bat file contains:

    cd C:\Users\danh\bin
    "C:\Program Files\Java\jre7\bin\java.exe" Signature
    
    • Daniel R Hicks
      Daniel R Hicks over 11 years
      I'm looking for a solution for this problem that works on Vista SP2 without installing other tools and will execute a simple (but continuously running -- on timer) Java app from Task Scheduler. I used to have this working somehow before my install got hosed but cannot figure out how to do it now that I've restored (sort of) my box. (I've not gotten the WshShell scheme to work -- the target bat file apparently never runs (or is killed immediately for some reason).)
    • Daniel R Hicks
      Daniel R Hicks over 11 years
      (The Java program has its own internal timer loop, meaning it continues to run after it's started.)
    • avirk
      avirk over 11 years
      @DanielRHicks check out this SU solution may be it can help you.
    • Ƭᴇcʜιᴇ007
      Ƭᴇcʜιᴇ007 over 11 years
      Can you provide the actual command being run by the Task?
    • Daniel R Hicks
      Daniel R Hicks over 11 years
      @techie007 -- See above, once the edit is approved.
  • Boeka
    Boeka over 13 years
    I'm afraid that's not possible because I need my kerberos credentials for some of the tasks.
  • Daniel R Hicks
    Daniel R Hicks over 11 years
    Doesn't seem to work.
  • Tamara Wijsman
    Tamara Wijsman over 11 years
    Already posted in another answer, doesn't seem to work.
  • harrymc
    harrymc over 11 years
    @TomWijsman: If you refer to the "/b" part, I only included it for completeness.
  • Daniel R Hicks
    Daniel R Hicks over 11 years
    I tried numerous variations of the start /b approach. Nothing seemed to eliminate the window -- I think it's been created by the time you begin executing the bat file, so by then it's too late.
  • Daniel R Hicks
    Daniel R Hicks over 11 years
    For the second approach, when I try to run it directly (by double-clicking the file) I get "Line: 3 Error: The system cannot find the file specified."
  • Ƭᴇcʜιᴇ007
    Ƭᴇcʜιᴇ007 over 11 years
    That was an example, not fully tested code. ;) Does java.exe exist at the path provided? Perhaps test with launching something simple like "notepad.exe", as java.exe can have some weird quirks sometimes.
  • Daniel R Hicks
    Daniel R Hicks over 11 years
    (Note the problem with the blank in the path name -- not clear how to deal with that.)
  • Ƭᴇcʜιᴇ007
    Ƭᴇcʜιᴇ007 over 11 years
    Using something like `c:\progra~1` may be easiest. ;) If your still stuck, I'm sure you can find lots of info on dealing with the space (and other script-related Q&A) over on StackOverflow.
  • Anthony Hatzopoulos
    Anthony Hatzopoulos about 9 years
    Similar question, with the same answer to use a vbs: serverfault.com/questions/9038/…
  • Fabian Röling
    Fabian Röling over 6 years
    Finally a solution that worked for me! But only after a restart.
  • Brent Rittenhouse
    Brent Rittenhouse almost 5 years
    btw, instead of doing c:\Windows\System32\cmd.exe you can just do %COMSPEC%, which is set to the command-prompt interpreter that's used. For more info see: en.wikipedia.org/wiki/COMSPEC