This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Hiding console when running Cygwin utility from Task Scheduler.

On 2017-08-02 17:40, Oleksandr Gavenko wrote:
> On 2017-08-02, Brian Inglis wrote:
>> Redirect all stdin from /dev/null, stdout, stderr to a log file in your
>> script , like:
>> 	#!/bin/bash
>> 	prog=${0##*/}
>> 	base=${prog%.*}
>> 	log=/var/log/$base.log
>> 	# do everything inside this wrapper
>> 	{
>> 		...
>> 	} < /dev/null &> $log
>> or equivalent on each command if you don't have many.
> That is not the case for:
> How can I prevent console to be shown when bash started from Task
> Scheduler?
> Closing of stdin / stdout / stderr is task for external process (like CRON) 
> even on UNIX.

I believe that conhost, mintty, ptys, cron, and Cygwin program startup open
handles for stdin, stdout, stderr to talk on, as those are assumed to be
available by most programs, rather than closing anything, which could terminate
program execution.

> With simple:
>   #include <stdio.h>
>   #include <unistd.h>
>   int main(int argc, char **argv) {
>       fclose(stdin);
>       fclose(stdout);
>       fclose(stderr);
>       sleep(10);
>       return 0;
>   }
> in Task Scheduler I see console window and supporting conhost.exe process.
> OK. I know about run.exe from package:
>   run
>   sdesc: "Launch cmdline programs with hidden console"
>   ldesc: "Launch cmdline programs with hidden console"
>   category: Base
>   requires: cygwin
>   version: 1.3.4-2
> I tried:
>   $ cp /bin/run.exe ~/usr/bin/runbash.exe
> and provide path to ~/usr/bin/runbash.exe in Task Scheduler. Console window
> still flashes.
> With my tiny test utility:
>   $ cp /bin/run.exe ~/usr/bin/runxtest.exe
> it flashes too from Task Scheduler but for a moment not 10 sec ))
> Same if I run by Win+R:
>   $ run xtest

Cygwin run allows you to run a Windows GUI program with a hidden console window.
I am never certain whether any Cygwin reference to Windows console and GUI
programs includes or excludes Cygwin command line and X Windows programs.

> My goal to avoid any splashes on screen and possible keyboard focus stealing
> from sudden task execution.

I never see any windows or conhost processes running Cygwin Scheduled Tasks with
the previous suggestions and these settings:

>> You may also have to set the (o) Run whether user is logged on or not
>> radio button, [X] Do not store password..., and [X] Run with highest
>> privileges check boxes.

where the first may be most significant in this case; the second avoids you
having to enter your password any time you make a change; the third is just for
luck! ;^> YMMV

Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]