From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8864 invoked by alias); 12 Jan 2015 16:40:35 -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 8855 invoked by uid 89); 12 Jan 2015 16:40:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.0 required=5.0 tests=AWL,BAYES_50,KAM_BODY_URIBL_PCCC,NO_DNS_FOR_FROM autolearn=no version=3.3.2 X-HELO: smtp-fr.alcatel-lucent.com Received: from Unknown (HELO smtp-fr.alcatel-lucent.com) (135.245.210.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 12 Jan 2015 16:40:15 +0000 Received: from us70tusmtp2.zam.alcatel-lucent.com (unknown [135.5.2.64]) by Websense Email Security Gateway with ESMTPS id 87FD815501078 for ; Mon, 12 Jan 2015 16:40:04 +0000 (GMT) Received: from US70UWXCHHUB02.zam.alcatel-lucent.com (us70uwxchhub02.zam.alcatel-lucent.com [135.5.2.49]) by us70tusmtp2.zam.alcatel-lucent.com (GMO) with ESMTP id t0CGdL5Z007429 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Mon, 12 Jan 2015 11:40:05 -0500 Received: from US70UWXCHMBA04.zam.alcatel-lucent.com ([169.254.12.84]) by US70UWXCHHUB02.zam.alcatel-lucent.com ([135.5.2.49]) with mapi id 14.03.0195.001; Mon, 12 Jan 2015 11:39:09 -0500 From: "Kertz, Denis (D)** CTR **" To: "cygwin@cygwin.com" Subject: Re: Can't Run Excel From A Cron Job Under Windows 7 Date: Mon, 12 Jan 2015 16:51:00 -0000 Message-ID: <883F2CBBC85A62419E181EB2F0ECF21F3E1419D3@US70UWXCHMBA04.zam.alcatel-lucent.com> References: <883F2CBBC85A62419E181EB2F0ECF21F3E1169F8@US70UWXCHMBA04.zam.alcatel-lucent.com> <3610637631.20141222030302@yandex.ru> In-Reply-To: <3610637631.20141222030302@yandex.ru> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg00192.txt.bz2 After more investigation, I agree that this isn't a cywin problem but this = isn't a GUI issue either. Something very strange is going on. Here is a test vb script to control Excel using the wscript engine (c:/Wind= ows/System32/wscript.exe). This vb script simply starts Excel, opens a .cs= v file (c:\Shared\Prospect\Bin\test.csv), and terminates: Dim xlApp Dim xlWb Set xlApp =3D CreateObject("Excel.application") xlApp.Visible =3D True Set xlWb =3D xlApp.workbooks.Open("c:\Shared\Prospect\Bin\test.csv") xlApp.Quit Set xlWb =3D Nothing Set xlApp =3D Nothing Here is the cron job to run this vb script: c:/Windows/System32/wscript.exe "c:\cygwin64\home\Upar2\bin\testExcel.vbs" When this cron job is run, it hangs with Excel running (and doing nothing). However, if the line that opens the .csv file is removed from this script: Set xlWb =3D xlApp.workbooks.Open("c:\Shared\Prospect\Bin\test.csv") Then the script runs successfully. That shows the cron job is running succ= essfully for this trivial Excel program that simply starts Excel and termin= ates Excel. This suggests there is a permission issue with opening the test.csv file bu= t that isn't the case. A cron job was run to simply cat the test.csv file = and this works: cat c:/Shared/Prospect/Bin/test.csv >$HOME/cat.out Finally, as was previously suggested, this script was executed using the ru= nas command and that works successfully: runas /user:\Upar2 "c:\Windows\System32\wscript.exe c:\cygwin6= 4\home\Upar2\bin\testExcel.vbs" A variation of this Excel script was created to create a new workbook (xlAp= p.Workbooks.Add) and save the workbook as a .xls file. This also results i= n Excel hanging when run as a cron job. So it appears the Excel script runs successfully as a cron job as long as n= o file operation (read or write) is performed which, of course, means no us= eful Excel script can be run. Any ideas? Denis -----Original Message----- From: Andrey Repin [mailto:anrdaemon@yandex.ru]=20 Sent: Sunday, December 21, 2014 6:03 PM To: Kertz, Denis (D)** CTR **; cygwin@cygwin.com Subject: [SPAM?] Re: Can't Run Excel From A Cron Job Under Windows 7 Greetings, Kertz, Denis (D)** CTR **! > I am trying to port a cygwin application that uses cron from a WinXP PC to > a Win7 Pro PC and I find some cron jobs won't run. Specifically, I need = to > run an Excel program from a cron job and this doesn't work on my Win7 PC. For posterity: Turned out, this has nothing to do with cygwin (predictable), and actually = has to do with how Windows (Vista+) manage services (namely: lack of access to = any GUI, unless you create one for yourself). The issue has been discussed, for example, at serverfault.com[1] and releva= nt MSDN article is [2]. The solution could be to create a stub application, which will make all necessary calls and then launch your GUI application in prepared environmen= t. [1] http://serverfault.com/questions/101671/scheduled-tasks-w-gui-issue [2] http://msdn.microsoft.com/en-us/library/ms687105(VS.85).aspx > In order to run an Excel program from cygwin I have this run.excel bash > script with an embedded VB script that executes an Excel program: > excel=3D$1 > vbscript=3D/usr/tmp/$$.vbs > cat <<-! >$vbscript > Dim xlApp > Set xlApp =3D CreateObject("Excel.application") > Set xlWb =3D xlApp.workbooks.Open("$excel") > xlApp.Quit > Set xlWb =3D Nothing > Set xlApp =3D Nothing > ! > chmod 777 $vbscript > c:/Windows/System32/wscript.exe 'c:\cygwin64\usr\tmp\$$.vbs' > An excel program is run like this: > run.excel 'c:\Shared\Bin\Create_Daily_Scorecard.xls' > When I run an Excel program interactively with this run.excel script it > runs just fine but when I run it via a cron job Excel just hangs. When > Excel hangs I can look at the processes running on the PC using the Windo= ws > Task Manager and I don't see the EXCEL.EXE process. But when I check the > option to show processes from all users I see the hung EXCEL.EXE process, > AND the user name displayed is my login. So I am running this under the > Upar2 login and Task Manager doesn't display EXCEL.EXE as a Upar2 process > but when I check 'Show processes from all users' it shows EXCEL.EXE runni= ng > under user name Upar2 - a contradiction. > What I suspect is happening is Excel is attempting to do something that > requires Upar2 permission but it isn't really running as Upar2 so Excel > displays some error message and is waiting for the user to respond. But > Excel is running invisibly so this can't be seen. > I also suspect this Upar2 "confusion" isn't limited to running an Excel > program. I can run a cron job with regular UNIX commands (cut, sort, etc) > and see they are running with the ps command. But when I try to kill them > (kill -9) I get permission denied. If I want to kill a process running v= ia > the cron I have to start cygwin with 'Run as administrator' and then I can > kill processes running under the cron. > So, does anyone know what's going on here and what I need to do get these > cron jobs running. As I noted at the beginning this is being ported from > WinXP, where all this works fine, to Win7. > I set up cron using cron-config like this: > $ cron-config > Do you want to install the cron daemon as a service? (yes/no) yes > Enter the value of CYGWIN for the daemon: [ ] > Do you want the cron daemon to run as yourself? (yes/no) yes > Please enter the password for user 'Upar2': > Reenter: > Running cron_diagnose ... > ... no problem found. > Do you want to start the cron daemon as a service now? (yes/no) yes > OK. The cron daemon is now running. > Denis -- WBR, Andrey Repin (anrdaemon@yandex.ru) 22.12.2014, <02:37> Sorry for my terrible english... -- 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