Hi all,
I've build a program in c# windows forms, now on the first load up it trys to create a scheduled tasks. if it raises exception and it's main computer then this is the first time the softwere loads(you can intall this program on many computer but one computer is the main with the scheduled tasks).
i've try this program on many computer and it worked perfectly(xp-sp1/2, vista-sp1/2, win7), now when i try to install it on a limited user(on win xp pro sp2) when it trys to create the scheduled tasks - i get a Argument Null Reference, and when i enter the admin user, it's install the scheduled task on the admin user and won't run if the limited user logged in(which is 99.9% of the time)...any ideas why i get this exception?? i've looked hours on the code to search where the exception come from but i can't find it! any one have ideas?
Thanks alot!
Amit.
MainOrSec = true; User, Pass are public varb whice return from FirstTimeUp.
private bool CreateNoExit()
{
try
{
RegistryKey key = Registry.CurrentUser;
key = key.OpenSubKey("Crm");
MainOrSec = Convert.ToBoolean(AESIMP.Decrypt((string)key.GetValue(AESIMP.Encrypt("MorS"))));
}
catch (ArgumentNullException)
{
MainOrSec = true;
}
if (MainOrSec)
{
ScheduledTasks sc = new ScheduledTasks();
Task task;
try
{
task = sc.CreateTask("NoExit");
FirstTimeUp f = new FirstTimeUp(this);
f.ShowDialog();
}
catch (ArgumentException)
{
return false;
}
if (!CreatT)
return false;
task.ApplicationName = @"C:\Program Files\Triffon\Crm Setup
2.0.0002\noexit.exe";
task.Comment = "Check For no exit on the database.";
task.SetAccountInformation(User, Pass);
task.IdleWaitMinutes = 10;
task.Triggers.Add(new DailyTrigger(5, 0));
try
{
task.Save();
task.Close();
sc.Dispose();
}
catch (COMException ex)
{
MessageBox.Show(ex.Message);
return false;
}
return true;
}
return false;
}