Home>

I want to restart the windows server and execute the batch from the task scheduler.
At this time, the task scheduler settings were specified as follows.

□ Program/Script
Batch name above
□ Start (optional)
Batch directory above

But after rebooting, the dos window will show c: \ windows \ system32 \ cmd.exe is displayed
Cd to the above directory and not running the batch.
Can you tell me how to improve this?
I want to set up the task scheduler so that the batch name is displayed in a separate dos window and the batch name

[Added]
--- pgm ---------------------
C: \ temp \ abc.cmd
↓ Contents
set aphome = C: \ ap
call"% aphome% \ AP server start PGM"

--- task ---------------------
Security option-Run only when the user is logged in
↑ No problem due to automatic login mechanism after reboot
Trigger ... Logon
Operation
Program ・ C: \ temp \ abc.cmd
Adding arguments ...
Start option-C: \ temp \

  • Answer # 1

      

    c: \ windows \ system32 \ cmd.exe

    The fact that "cmd.exe" is written in this way is the title bar (where there is a × or minimize button)?
    Because it is a place where the body of the command prompt program is located, even if it is displayed as it is, I can not say that `` cd to the above directory and batch is not executed '' (cd properly) So it will be displayed).

    @ECHO ON, and what is written before>I think you need to check if it isnotrun at \ temp \" ;.

    -Add
    I would like to remind you that you do not understand, but even if such a notation appears, the setting of the working folder is working.

    REM one.cmd
    @ECHO ON
    echo "this is 1!">>1.txt
    PAUSE
    REM two.cmd
    @ECHO ON
    echo "this is 2!">>1.txt
    PAUSE


    These
    C: \ bin
    -one.cmd
    -two.cmd
    C: \ temp1
    -empty
    C: \ temp2
    -empty

    In this configuration, the task scheduler

    <? xml version = "1.0" encoding = "UTF-16"?>
    <Task version = "1.2" xmlns = "http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
        <Date>2018-08-23T21: 36: 01.7920025</Date>
        <Author>me</Author>
        <URI>\ one</URI>
      </RegistrationInfo>
      <Triggers>
        <LogonTrigger>
          <Enabled>true</Enabled>
          <UserId>papinianus</UserId>
        </LogonTrigger>
      </Triggers>
      <Principals>
        <Principal id = "Author">
          <UserId></UserId>
          <LogonType>InteractiveToken</LogonType>
          <RunLevel>HighestAvailable</RunLevel>
        </Principal>
      </Principals>
      <Settings>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>true</AllowHardTerminate>
        <StartWhenAvailable>false</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <IdleSettings>
          <StopOnIdleEnd>true</StopOnIdleEnd>
          <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>false</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <WakeToRun>false</WakeToRun>
        <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
        <Priority>7</Priority></Settings>
      <Actions Context = "Author">
        <Exec>
          <Command>c: \ bin \ one.cmd</Command>
          <WorkingDirectory>c: \ temp1</WorkingDirectory>
        </Exec>
      </Actions>
    </Task>
    <? xml version = "1.0" encoding = "UTF-16"?>
    <Task version = "1.2" xmlns = "http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
        <Date>2018-08-23T21: 36: 36.9287388</Date>
        <Author>me</Author>
        <URI>\ two</URI>
      </RegistrationInfo>
      <Triggers>
        <LogonTrigger>
          <Enabled>true</Enabled>
          <UserId>papinianus</UserId>
        </LogonTrigger>
      </Triggers>
      <Principals>
        <Principal id = "Author">
          <UserId></UserId>
          <LogonType>InteractiveToken</LogonType>
          <RunLevel>HighestAvailable</RunLevel>
        </Principal>
      </Principals>
      <Settings>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>true</AllowHardTerminate>
        <StartWhenAvailable>false</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <IdleSettings>
          <StopOnIdleEnd>true</StopOnIdleEnd>
          <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>false</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <WakeToRun>false</WakeToRun>
        <ExecutionTimeLimit>PT1H</ExecutionTimeLimit>
        <Priority>7</Priority>
      </Settings>
      <Actions Context = "Author">
        <Exec>
          <Command>C: \ bin \ two.cmd</Command>
          <WorkingDirectory>c: \ temp2</WorkingDirectory>
        </Exec>
      </Actions>
    </Task>


    When executed with this setting

    As shown in the above, regardless of the title bar, it was executed with the working folder in effect, and c: \ temp1 \ 1.txtg and c: \ temp2 \ 1.txt were created (two lines were written to system32) 1.txt was not made.)

    If you don't agree with this and it doesn't fit the touch, if you want to cd it, create a launcher cmd,

    REM launch.abc.cmd
    cd/d C: \ temp
    abc.cmd


    Just do that.