How to send a Yes parameter to overwrite a schedule from command line in vb.net
Solution 1
You may use schtasks.exe /Query
to check if the task already exist and then /F
flag to force delete / replace without warnings.
Solution 2
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 .
Javier Salas
I like to learn, travel and discover new things and places. Music is my passion and programming has become one of the things that I like to do!
Updated on June 19, 2022Comments
-
Javier Salas about 2 years
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