I'm developing and application and I'm creating scheduled tasks from command line using vb.net.
When I'm trying to create an existing schedule the command line window come asking if we want to overwrite the existing schedule tasks, My question is:
How Can I send automatically that parameter if I ask it using a message box, if the user answer yes, it will replace automatically the schedule task.
This is how I'm doing that:
Dim KeyToSend as string = " /Create /SC MONTHLY /D 11 /TN "SFTP_FILE_Javier" /TR "\"C:\Users\salasfri\Documents\Visual Studio 2012\Projects\prjFileTrans20151102\prjFileTrans\prjFileTrans\bin\Debug\prjFileTrans.exe\" SFTP_FILE" /ST 16:44"
taskProcess.StartInfo = New ProcessStartInfo(Environment.SystemDirectory + "\SchTasks.exe", KeyToSend)
taskProcess.Start()
When the line come to the line taskProcess.Start() the command prompt windows appear asking if we want to replace the schedule task and we have to input Y/N depending if we want to do it.
I want to do that automatically
I tried with using taskProcess.StartInfo.Arguments = "Y" but it didn't work
any idea?
Thanks
You may use schtasks.exe /Query
to check if the task already exist and then /F
flag to force delete / replace without warnings.
Reference
Declare a boolean as False , then use if statement
Dim Value as Boolean = false
if (condition)
value = true
else
value = false
End if
if (value = true)
'' start you application
i think you are searching for this .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With