surf-build / surf

The simplest GitHub build server
MIT License
402 stars 25 forks source link

Windows: surf-install thinks schtasks fails, but it appears to succeed #64

Open rfay opened 7 years ago

rfay commented 7 years ago

I tried running surf-install, and it claimed it failed:

 surf-install --name surf-windows-ddev -c "surf-run --repo https://github.com/rfay/ddev --jobs 1 -- surf-build --name surf-windows"
Can't load runas, if this fails try re-running as Elevated Admin
Fatal Error: Failed to run schtasks, exited with undefined

However, when I look at the task scheduler, it seems to have been inserted just fine, and when I restart/login the task runs.

Windows 10, in administrative cmd window. surf 1.0.4

BTW, I've basically had great success with surf. Thank you! We're able to use it for one-off configurations that circleci and appveyor just can't do for us.

anaisbetts commented 7 years ago

I wonder if schtasks is returning non-zero even when it succeeds 🤔

rfay commented 7 years ago

I spent a little time with this but didn't sort it out yet.

It looks to me like schtasks works just fine with the xmlfile and everything else it has created, which makes sense because it all works:

schtasks /Create /Tn junker999 /xml f-117628-3488-8hy2cy.4z11owp14i
SUCCESS: The scheduled task "junker999" has successfully been created.

C:\Users\rfay\AppData\Local\Temp>echo %ERRORLEVEL%
0

I suspect that runAsAdministrator() just isn't up to the task of capturing the return value of a windows command execution.

The (untouched) generated xml, which works fine with manual invocation as above, is at https://gist.github.com/rfay/1b669521f7b0bc9e010ccff24b0844b8

rfay commented 7 years ago

However, just for posterity (don't think these are the problem) some links on schtasks returns: