본문 바로가기
카테고리 없음

Windows 작업 스케줄 입력 명령어 2

by 호야호잇 2019. 10. 29.

        'If File.Exists(UpdatePath) = True Then

        '    'Dim 시작위치 As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\" & StartName
        '    'File.Delete(시작위치)
        '    Dim CHK_Process As New Process()
        '    Dim CHK_CMD As New ProcessStartInfo
        '    CHK_CMD.UseShellExecute = False
        '    CHK_CMD.RedirectStandardOutput = True
        '    CHK_CMD.FileName = "cmd.exe"
        '    CHK_CMD.Arguments = "/c SCHTASKS /Query"
        '    CHK_CMD.CreateNoWindow = True
        '    CHK_Process.StartInfo = CHK_CMD
        '    CHK_Process.Start()

        '    '--- 기존스케줄에 등록되어있는지 확인
        '    Dim CMD_Output As String = ""
        '    Using CMD_StreamReader As System.IO.StreamReader = CHK_Process.StandardOutput
        '        CMD_Output = CMD_StreamReader.ReadToEnd()
        '    End Using

        '    '-- 스케줄 등록
        '    If InStr(CMD_Output, UpdateAppName) < 1 Then

        '        Dim REG_PATH As String = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\SERVICETOP"
        '        Dim CHK_REG As RegistryKey = Registry.LocalMachine.OpenSubKey(REG_PATH)
        '        Dim RUN_CMD As New ProcessStartInfo()
        '        RUN_CMD.Verb = "runas"
        '        RUN_CMD.FileName = "cmd.exe"
        '        RUN_CMD.Arguments = "/c  SCHTASKS /Create /SC ONLOGON /TN SERVICETOP\"
        '        RUN_CMD.Arguments += ProgramFolder & " /TR " & Chr(34) & Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)
        '        RUN_CMD.Arguments += "\" & ProgramFolder & "\" & UpdateAppName & ".exe" & Chr(34) & " /RL HIGHEST"
        '        RUN_CMD.WindowStyle = ProcessWindowStyle.Hidden
        '        Process.Start(RUN_CMD) '- 스케줄 등록


        '    End If
        'End If