Wondered if anyone could advise me on something.
I've followed this guide to creating a service Creating Services with VB Express | DoTheWeb.net and the service seems OK.
However what I'm wanting to do is to check whether a scheduled task is in the C:\Windows\Tasks folder.
My code for checking is this;
In event viewer you can see the logs stating that the task is missing. it then appears to be calling the sub CreateScheDSMTask which looks like this;
If System.IO.File.Exists("C:\Windows\Tasks\DSM.job") = True Then
Diagnostics.EventLog.WriteEntry("Check For DSMLog", "DSM Task Is Missing", EventLogEntryType.Error)
Diagnostics.EventLog.WriteEntry("Check For DSM Log", "DSM Task Has Been Recreated.", EventLogEntryType.Information)
However when I look in Task Manager Schtasks.exe is sat there appearing to be stuck.
Dim foo1 As New System.Diagnostics.Process
foo1.StartInfo.WorkingDirectory = "C:\Windows\System32"
foo1.StartInfo.RedirectStandardInput = True
foo1.StartInfo.RedirectStandardOutput = True
foo1.StartInfo.RedirectStandardError = True
foo1.StartInfo.FileName = "schtasks.exe"
foo1.StartInfo.Arguments = "/Create /SC hourly /MO 1 /TN DSM /ST 01:00:00 /RU Administrator /RP " & Environment.GetEnvironmentVariable("AdmP") & " /TR ""\""" & "C:\Program Files\DSM\DSM.exe"""""
foo1.StartInfo.UseShellExecute = False
foo1.StartInfo.CreateNoWindow = True
foo1.StartInfo.WindowStyle = ProcessWindowStyle.Normal
Now, if I stick the above sub (CreateSheDSMTask)in a new project on a Button on a simple windows form, the task is created successfully.