I have a C# .exe file i want to sechdule it in task sechduler.It is running a script so i want that when i am sechduling it
,from there i will pass my script file name,i do not want that it is hardcoded in source code.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mahesh ChandRank #1 · 393.3K reputationPosted Sep 6, 2010, 6:59 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Sep 6, 2010, 11:24 AM EDT
Dipal ChoksiRank #199 · 12K reputationPosted Sep 6, 2010, 5:56 PM EDT
eg.
try searching (google) for "windows scheduler specify parameters" for specific examples.
Your executable will receive the runtime arguments within the args parameter of the main method
Hope this helps!
Dipal
Neerav Sachdeva33 reputationPosted Sep 6, 2010, 9:39 PM EDT
Here is my sample code:-
/////////////////////////////////////////////////////
Process scriptProc = new Process();
scriptProc.StartInfo.FileName = @"cscript";
//string filePath5 = @"D:\LogRotation\vbsource\NewTextDocument.txt";
string filePath5 = @"G:\Failure Notification\VBScriptSource\vbsourcefile.txt";
string vbfile = null;
if (File.Exists(filePath5))
{
StreamReader file5 = null;
try
{
file5 = new StreamReader(filePath5);
while ((vbfile = file5.ReadLine()) != null)
{
//Console.WriteLine(line);
//oMsg.From = fromfile;
scriptProc.StartInfo.Arguments = @"//B //Nologo " + vbfile;
}
}
finally
{
if (file5 != null)
file5.Close();
}
}
else
{
Console.Write("vbfile does not exist");
}
//scriptProc.StartInfo.Arguments = @"//B //Nologo D:\logrotationex\source\logfiledb.vbs";
scriptProc.Start();
scriptProc.WaitForExit();
Console.Write("executed");
scriptProc.Close();
lalit pant3 reputationPosted Sep 6, 2010, 9:48 PM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Sep 7, 2010, 3:06 AM EDT
Neerav Sachdeva33 reputationPosted Sep 12, 2010, 12:01 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Sep 12, 2010, 1:11 AM EDT
Neerav Sachdeva33 reputationPosted Sep 12, 2010, 1:19 AM EDT
that to be a good developer we have to always read lot of thing.Thanks for your concern I will really appreciate you If you will help me on this and tell me about the Documentation.
Neerav Sachdeva33 reputationPosted Sep 12, 2010, 1:19 AM EDT
that to be a good developer we have to always read lot of thing.Thanks for your concern I will really appreciate you If you will help me on this and tell me about the Documentation.
Sam HobbsRank #107 · 20.5K reputationPosted Sep 12, 2010, 9:47 AM EDT