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: Unable to run excel via cron


> On 06/23/2015 09:39 AM, Kertz, Denis (D)** CTR ** wrote:
> > I changed the cron setup to use cygserver as Corinna suggested.  I used
> > cron-config and cygserver-config to setup the cron and cygserver services
> > and passwd -R to establish my password.  Normal cron jobs run under this
> > setup but Excel still hangs as it did before.  I also tried this on the
> > Win7 PC that I thought worked at one time but it behaved the same with
> > Excel hanging.
> >
> > So it looks like Corinna's first case is the situation - there is no
> > solution.  There apparently is something unique about Excel that will not
> > run in this Win7 cron environment.
> 
> It's actually not unique to Excel and it's not peculiar to Cygwin's cron.
> Any program that requires desktop interaction to run would suffer this same
> limitation on Vista and beyond if started from a service.  In the Cygwin
> environment, cron is run as a service and used to start programs, so it's
> the obvious 'culprit' reported here but it's just one of many possible
> vectors that exhibit the unwanted behavior on Windows.  Just FYI.
> 
> --
> Larry
> 
I think Denis is saying Excel hangs even if it doesn't require user interaction. 
 I.e.  it runs some macros and exits.   On Win7 Pro, I was able to run the following 
.vbs script via the task scheduler and have it run the  "AddTimeInColumn" macro.
The resulting spreadsheet had the times the task was run column A.

Andy

Here's the .vbs script:

Dim args, objExcel

Set args = WScript.Arguments
Set objExcel = CreateObject("Excel.Application")

objExcel.Workbooks.Open("C:\cygwin64\home\Andy\ExcelTest\TestExcel.xlsm")
objExcel.Visible = True

objExcel.Run "AddTimeInColumn"

objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close(0)
objExcel.Quit

Here's the macro:

Public Sub AddTimeInColumn()

    Dim LastRowInColumn As Long
    
    LastRowInColumn = Cells(Cells.Rows.Count, "A").End(xlUp).Row
    
    'If column is completely blank, need to adjust last row
    If Cells(LastRowInColumn, "A").Value = "" Then LastRowInColumn = 0
    
    'Insert time in next row
    Cells(LastRowInColumn + 1, "A").Value = Time()

End Sub




--
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


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