Results 1 to 2 of 2

Thread: Shelling exe's from a service using SYSTEM account

  1. #1
    Swain90 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Dec 2013
    Posts
    4
    Reputation
    0

    Shelling exe's from a service using SYSTEM account

    Hi All,

    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;

    Code:
         If System.IO.File.Exists("C:\Windows\Tasks\DSM.job") = True Then  
          Else
                Diagnostics.EventLog.WriteEntry("Check For DSMLog", "DSM Task Is Missing", EventLogEntryType.Error)
               Call CreateScheDSMTask()
                Diagnostics.EventLog.WriteEntry("Check For DSM Log", "DSM Task Has Been Recreated.", EventLogEntryType.Information)
            End If
    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;

    Code:
    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
            foo1.Start()
            foo1.WaitForExit()
    However when I look in Task Manager Schtasks.exe is sat there appearing to be stuck.

    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.

    Any Ideas???

    Cheers

    Swain90
    Last edited by Swain90; 05-30-2014 at 6:50 AM.

  2. #2
    Swain90 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Dec 2013
    Posts
    4
    Reputation
    0
    Used Shell("C:\AppPath\Exe.exe") and that seems to work

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •