From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124122 invoked by alias); 3 Aug 2017 05:21:44 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 124099 invoked by uid 89); 3 Aug 2017 05:21:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=Win, mintty, 1.3.4-2, stealing X-HELO: smtp-out-no.shaw.ca Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 03 Aug 2017 05:21:40 +0000 Received: from [192.168.1.100] ([24.64.240.204]) by shaw.ca with SMTP id d8ZkdaJT2I8mCd8ZldGhB0; Wed, 02 Aug 2017 23:21:38 -0600 X-Authority-Analysis: v=2.2 cv=HahkdmM8 c=1 sm=1 tr=0 a=MVEHjbUiAHxQW0jfcDq5EA==:117 a=MVEHjbUiAHxQW0jfcDq5EA==:17 a=IkcTkHD0fZMA:10 a=pbte3n_TCjoSnnkzv0gA:9 a=QEXdDO2ut3YA:10 Reply-To: Brian.Inglis@SystematicSw.ab.ca Subject: Re: Hiding console when running Cygwin utility from Task Scheduler. To: cygwin@cygwin.com References: <86o9ryymx5.fsf@gavenkoa.example.com> <8660e5wnb6.fsf@gavenkoa.example.com> From: Brian Inglis Message-ID: Date: Thu, 03 Aug 2017 05:21:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <8660e5wnb6.fsf@gavenkoa.example.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfIUvWttib2y9X9ApLLb3Po9OvRwv421G7e5Y4dhn2sH4a9LEBwjjYStv4zVy6F0w+1A4vodEnG1xuus8p2jx6xKgeQCRAHYbOuc9OQqoKlVJ0zpi53Mi XdS9eoIeocogzQh6pNcxTe6d+ZbNLbq+x8n/Cvy9xAYG9wtCgS+lhIWP840nhnqqLK3LQrZ6irUNXw== X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00038.txt.bz2 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 > #include > > 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: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple