Sign in with
Sign up | Sign in
Your question

0x1: An incorrect function was called or an unknown function was called

Last response: in Windows XP
February 18, 2011 8:32:12 AM

I've an error related with Sheduled tasks in windows server 2003.

I'm using Microsoft.Win32.TaskSheduler.dll to add a bat file to the Sheduled tasks.

When I add the file manually, there is no problem but when i try to add the file via code(I'm using C#).

Here is the code i'm using:

TaskService ts = new TaskService();

TimeTrigger tt = new TimeTrigger();
tt.StartBoundary = DateTime.Now;

tt.Enabled = true;
tt.Repetition.Duration = TimeSpan.FromMinutes(5);
tt.Repetition.Interval = TimeSpan.FromMinutes(1);

// Create a new task definition and assign properties
TaskDefinition td = ts.NewTask();

string exec_action = "c:\folder\file.bat"

new ExecAction(exec_action,
null, null

string taskName = "taskName";

ts.RootFolder.RegisterTaskDefinition(taskName, td
null, null,

In the string exec_action, if i put there "notepad.exe", the task "fires" and the note pad opens, but if i put there the bat file, i see the cmd console opening and closing very fast but nothing happens.
If i run the bat file with "double click" it also works well.

I don't know what i'm missing here, if someone can help me, i would be thankful!
February 18, 2011 10:58:26 AM

Have you tried making the exec_action "cmd" and then using the /C switch to specify the batch file?
February 18, 2011 11:43:38 AM

Ijack said:
Have you tried making the exec_action "cmd" and then using the /C switch to specify the batch file?

I've solverd the problem! :) 

The problem was in the bat file.

The bat file calls a "exe" file . They are both located in the same directory.

So in the bat file i had only put the name of the "exe" and not the complete file path.
TaskSheduler runs in the system32 folder, so it needs the complete path of the "exe".

And that's it...problem solved!!

The complete path of the "exe" file was all i needed.