1

I have a c# console app that uploads data to a Sitecore/UCommerce implementation. It is based on the UCommerce UConnector. When I run this from the command line it executes without a problem all data is uploaded and downloaded correctly without error. When I try to schedule this task it exits with a 0xffffff error. The task specifies a command line parameter that sets the app to read all configurable options from the App.Config

I have search this error and found many suggestions which I have tried but none are solving this problem. Things I have tried include:

  • Entering a Start In parameter
  • Checking Run with highest privilege's
  • Converting Console App to Windows Forms app with no forms
  • Using Administrator account to run task
  • Setting security permissions on the folder the app is in to full control
  • Running under the System account
  • Tried running the same task on a Server (Windows Server 2012) and Workstation (Windows 7)

None of these have made any difference. Nothing in logged in the event viewer. The error logging (SQL) in the app logs nothing.

I don't know if this has any relevance but the app is using NHibernate, Castle Windsor and of course UCommerce.

Can anyone suggest anything I have not yet tried? Or suggest how I can find out what the error might be.

Edit

Here is the command line command as requested

Command Line

Update

(I have removed all the spaces in the path just in case that was causing an issue so command below is a different path than the image above)

I have managed to get the config changed on the server and create a batch file. I have also changed the folder the app is in so there are no spaces in the path. in the batch file I have

cmd /c F:\SCProcessor\Orders\SiteConnector.exe /cfg

I have the same error being repored in Task Scheduler

If I double click the batch file it runs perfectly. If I change the /c to /k (hoping to see an error reported in the command window) no window shows and the task does not stop running until I end it.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Fred
  • 5,663
  • 4
  • 45
  • 74
  • how do execute it from command line. can you share your command and the directory from where you execute it? One alternate way would be>> to create a batch file which contains command to execute your application and call that batch file in your schedule task – amit dayama Oct 14 '15 at 12:57
  • @amitdayama please see edit I tried the batch file approach but this task needs to run on the Windows 2012 Server and when I tried to create a batch file the server reported back that batch files were not allowed. – Fred Oct 14 '15 at 13:02
  • quite possible that you c sharp console app is calling your exe file with some other working folder? Does your console app also consider working folder ? – amit dayama Oct 15 '15 at 04:21
  • The C# Console app is not calling an exe. I am trying to run the ConsoleApp.exe from a scheduled task. – Fred Oct 16 '15 at 07:58
  • My bad.. Did you check schedule task Logs. Its under C:\Windows\Schedlgu.txt – amit dayama Oct 16 '15 at 08:20
  • @amitdayama Couldn't find any logs that gave me a clue to the problem. SSMS did :) The solution I found is below. – Fred Oct 16 '15 at 09:23

1 Answers1

1

Ok I have fixed my own problem. It took a while to find out what the problem actually was but eventually I found it by running this in SSMS and xp_cmdshell. This reported back that it could not find a config file

C:\windows\system32\app_config\prefetch\Common.config

app_config is a folder in the console apps folder. In the SiteConnector.exe.config is a number of includes that pull in various configs:

 <sc.include file="App_Config/Prefetch/Common.config"/>

For whatever reason (and I still have to work out why) this resolves to:

C:\windows\system32\app_config\prefetch\Common.config

When calling it from task scheduler or a SQL job but:

F:\SCProcessor\Orders\app_config\prefetch\Common.config

When run from the command prompt.

I changed the paths for the includes to absolute paths and the problem is fixed. Just need to update the SiteConnector.exe.config to something like

<sc.include file="{$CurrentFolder}/App_Config/Prefetch/Common.config"/>

If that is possible.

Fred
  • 5,663
  • 4
  • 45
  • 74
  • This is because you schedule task runs under working folder C:\Windows.. so it was looking at the location C:\windows\system32\app_config\prefetch\Common.config. for testing purpose: If you create a simple schedule task to create a folder (By giving command mkdir testfolder). It would create inside C:\Windows. – amit dayama Oct 16 '15 at 09:27
  • But the Start in folder was set to F:\SCProcessor\Orders\ so why did this not work? I also put the command in a batch file and added `cmd F: & cd SCProcessor\Orders & SiteConnector.exe /cfg` same problem – Fred Oct 16 '15 at 09:36
  • Then it should not happen. or may be there is something in your console app which was doing so.. – amit dayama Oct 16 '15 at 09:39