Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClickOnce app not starting from the scheduler

I have a batch file that will bounce a clickOnce app:

@REM The odd PING statements are to create a 5 second wait
@echo off
taskkill /F /IM MyApp.exe
PING 1.1.1.1 -n 1 -w 5000 >NUL
"%USERPROFILE%\Path\To\My\App.appref-ms"

This works fine when I double-click it: the process is killed and then restarted after 5 seconds.

However, if I schedule the task, it kills the process, but doesn't restart it.

Does anybody know what's going on? (The task is running as the same user I am logged on as when I double click the batch file and all works well)

Thanks

Ryan

like image 728
Ryan Avatar asked Jun 24 '10 12:06

Ryan


Video Answer


2 Answers

I had the same problem under Windows Server 2012 R2. My ClickOnce application would run when starting manually and not always run when started from Task Scheduler.

I found out it was due to dfsvc.exe (ClickOnce service helper) not starting up correctly from Task Scheduler. My solution was to point the Task to a batch file which would start up dfsvc.exe prior to starting the ClickOnce application :

:: Run ClickOnce service if not already running
tasklist /NH /FI "IMAGENAME eq dfsvc.exe" 2>NUL | find /I "dfsvc.exe">NUL
if errorlevel 1 start "" "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\dfsvc.exe"

\\the\path\to\your.application
like image 92
Wizou Avatar answered Oct 12 '22 14:10

Wizou


I know this is really old, but I am writing because I could not find answers.

(Environment: VS2010, C# console app with updates targeting .net 3.5 on Win 7 64)

I could not get a console app to run in task scheduler. My app is published to the network file share. Task Scheduler failed to run \AutoSync.application with a "%1 is not a valid win32 application" error. Task Scheduler would say that \setup.exe ran successfully, but none of the procedures that the app did appeared to be done, including the status email it sent before closing. It did not matter if I used the UNC path or a lettered mapped drive, nothing would work. I did not try publishing to the local machine, it was out of the question for me.

The app would run perfectly when ran manually. Then I followed the path that my start menu shortcut used - "C:\Users\foo\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\AutoSync\" and selected the shortcut found there. It filled the actual exe path "C:\Users\foo\AppData\Local\Apps\2.0\W9BDW4LH.KM0\J6DPJEM9.LT0\auto..tion_a217eb88f33937fd_\AutoSync.exe". This was all that I needed.

My program now runs on a daily schedule and emails me upon completion. However, I am prepared to redo my task's action after the next update.

like image 43
wruckie Avatar answered Oct 12 '22 15:10

wruckie