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 10:06, Oleksandr Gavenko wrote:
> I prepared backup task in Bash script and added task to run it in Windows Task
> Scheduler:
>   Executable: c:\opt\cygwin\bin\bash.exe
>   Params: c:\home\backup\backup-job.bash
> Each time job run I see console screen. 'procmon' shown that it is::
>   \??\C:\Windows\system32\conhost.exe 0xffffffff -ForceV1
> Seems each Cygwin utility brings console into foreground. I also tested with:
>   c:\opt\cygwin\bin\yes.exe
> How can I prevent console to be shown when bash started from Task Scheduler?

Redirect all stdin from /dev/null, stdout, stderr to a log file in your script ,

	# do everything inside this wrapper
	} < /dev/null &> $log

or equivalent on each command if you don't have many.

Ensure you always use the correct hashbang path and the script is executable.

You might also want to change your Task Action Arguments to:
	-- /proc/cygdrive/c/home/backup/backup-job.bash
to indicate "--" end of options, there are no options, just args, and use Cygwin
paths for all file arguments.

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

I have found it useful to Cygwin symlink all cron/Task scripts to
/usr/local/bin/ and use that path for all script jobs.

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]