powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Windows [игнор отключен] [закрыт для гостей] / schtasks
26 сообщений из 26, показаны все 2 страниц
schtasks
    #38245726
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
задача - создать task который будет запускаться через 5 мин. т.е. текущее время + 5 мин.
собрал что-то такое
Код: sql
1.
2.
schtasks /create /sc ONCE /tn tname /tr calc.exe -z
ERROR: No value specified for /ST option.


так же в хепе указано
автор /ST starttime Specifies the start time to run the task. The time
format is HH:mm (24 hour time) for example, 14:30 for
2:30 PM.
Код: plaintext
1.
Defaults to current time if /ST is not specified. This option is required with /SC ONCE.


подскажите пож. как.
...
Рейтинг: 0 / 0
schtasks
    #38246159
неТолик1
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
_human,

Managing Tasks with the SCHTasksCommand
The Schedule Tasks (SchTasks) Command helps you schedule tasks at the command line. The basic
command line requires that you provide a parameter (an action or command) and any arguments
that the parameter requires. The list of recognized parameters includes /Create, /Delete, /Query,
/Change, /Run, and /End. The following sections describe each of these parameters.
/Create
The /Createparameter helps you create new tasks. Never use this parameter to change an existing
task; use the /Changeparameter instead. This parameter uses the following syntax:
SCHTASKS /Create [/S system [/U username [/P password]]] [/RU username
[/RP password]] /SC schedule [/MO modifier] [/D day] [/I idletime]
/TN taskname /TR taskrun [/ST starttime] [/M months] [/SD startdate]
[/ED enddate] [/RI interval] [ {/ET endtime | /DU duration} [/K]
[/XML xmlfile] /V1]] [/IT | /NP] [/Z] [/F]
The following list describes each of the standard command line arguments.
/S system Specifies the remote system that you want to check. In most cases, you’ll also need
to supply the /Uand the /Pcommand line switches when using this switch.
/U [domain]user Specifies the username on the remote system. This name may not match the
username on the local system. You’ll need to supply a domain name when working with a
domain controller.
/P [password] Specifies the password for the given user. You can provide the command line
switch without specifying the password on the command line in cleartext. The system prompts
you for the password. Using this feature can help you maintain the security of passwords used
on your system.
/RU username Specifies the user account or user context that you want to use to run the
task. Use “”, “NT AUTHORITY\SYSTEM”, or “SYSTEM”to use the system account to run the task.
/RP password Specifies the password of the user account or user context you want to use to
run the task. Use an asterisk (*) or a blank (nothing after the command line switch) in place of
the password when you want the system to prompt you for the password. This command line
switch has no effect when you use the system account to run the task.
206 CHAPTER 8 PERFORMING TASK AUTOMATION
/SC schedule Defines the frequency at which the system runs the task. The valid frequencies
include MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON,
and ONIDLE.
/MO modifier Refines the schedule type to provide finer control over the schedule frequency.
The modifier you use depends on the scheduling frequency. The following list describes each of
the modifiers.
MINUTEEvery 1–1,439 minutes
HOURLY Every 1–23 hours
DAILY Every 1–365 days
WEEKLYEvery 1–52 weeks
ONCE No modifiers
ONSTART No modifiers
ONLOGON No modifiers
ONIDLE No modifiers
MONTHLYEvery 1 to 12 months, or FIRST, SECOND, THIRD, FOURTH, LAST, or
LASTDAY
/D days Specifies the day of the week to run the task. Acceptable values include MON, TUE,
WED, THU, FRI, SAT, and SUN. When working with a monthly schedule, you can specify date
numbers between 1 and 31.
/M months Specifies the month of the year to run a task. The default setting is the current
month. Acceptable values include JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT,
NOV, and DEC.
/I idletime Specifies the amount of time to wait before running a scheduled ONIDLE task.
Idle time is when no other application on the system is running (the system idle process is using
all of the computer resources). The acceptable range of values is 1 to 999 minutes.
/TN taskname Specifies the name of the task. The utility requires a unique name for the
purpose of identification.
/TR taskrun Specifies the full path and filename of the task that you want to run. Never
assume that the task will run based on a PATHenvironment variable because you can’t guarantee
the user will have the environment variable defined. You can also specify any command line
arguments that the task requires. Enclose tasks with spaces in quotes.
/ST starttime Specifies the time that you want the task to run. The time format is
HH:MM:SS (24-hour time). Don’t use a 12-hour time format that includes AM and PM. The
default setting is the current time.
/SD startdate Specifies the first date on which to run the task. The date format is mm/dd/
yyyy. Always include a 4-digit year. The default setting is the current day.
/ED enddate Specifies the last date that you want to run the task. The date format is mm/dd/
yyyy. Always include a 4-digit year. The default is not to use an end time, so the task continues
to run indefinitely.
/RI interval Specifies the repetition interval of the task in minutes. You can’t use this feature with schedule types of MINUTE, HOURLY, ONSTART, ONLOGON, ONIDLE, and
SCHEDULING AND MANAGING TASKS 207
ONEVENT. The valid range for this argument is 1 to 599,940 minutes. If you specify either the
/ETor /DEcommand line arguments, then the default interval is 10 minutes.
/ET endtime Specifies the end time of the task. The time format is HH:MM:SS (24-hour time).
Don’t use a 12-hour time format that includes AM and PM. You can’t use this feature with
schedule types of ONSTART, ONLOGON, ONIDLE, and ONEVENT. It also isn’t possible to use
this feature with the /DUoption.
/DU duration Specifies the duration of the task. The time format is HH:MM (a time interval
in hours and minutes, not a specific time). You can’t use this feature with schedule types of
ONSTART, ONLOGON, ONIDLE, and ONEVENT. It also isn’t possible to use this feature with
the /EToption. When you specify the /RIargument with a /V1task, the default duration is
1 hour.
/K Automatically terminates the task at the end time or after the duration interval expires.
You can’t use this feature with schedule types of ONSTART, ONLOGON, ONIDLE, and
ONEVENT. This argument is only applicable when you specify either the /ETor /DUcommand
line arguments.
/XML xmlfile Creates a task based on the task XML in the specified file. Combine this command line switch with the /RUand /RPcommand line switches to specify a complete entry
(including security). The task XML can also contain the principal, which means that you only
supply the /RUcommand line switch.
/V1 Creates a task that’s compatible with pre-Vista versions of Windows. If you don’t use this
command line switch on a Vista system, then other versions of Windows can’t see the task you
create. You can’t use this command line switch with /XML.
/IT Forces the task to run interactively only. The job runs when the user is logged on, but Vista
and above ignores it when the user is logged out.
/NP Disables password storage. The job runs noninteractively using the credentials of the
specified user. The job can only access local resources. Using this command line switch improves
security by not storing the password and by reducing task access to external resources.
/Z Marks the task for deletion after its final run (as specified in the schedule you provide). The
job isn’t actually deleted—Vista only marks it for deletion.
/F Forces task creation even if a task by that name already exists on the system. Vista and
above doesn’t display any warning messages, it simply overwrites the existing job.
/Delete
The /Deleteparameter deletes tasks that you no longer want to run. This parameter uses the
following syntax:
SCHTASKS /Delete [/S system [/U username [/P password]]] /TN taskname [/F]
The following list describes each of the command line arguments.
/S system Specifies the remote system that you want to check. In most cases, you’ll also need
to supply the /Uand the /Pcommand line switches when using this switch.
/U [domain\]user Specifies the username on the remote system. This name may not match
the username on the local system. You’ll need to supply a domain name when working with a
domain controller.
208 CHAPTER 8 PERFORMING TASK AUTOMATION
/P [password] Specifies the password for the given user. You can provide the command line
switch without specifying the password on the command line in cleartext. The system prompts
you for the password. Using this feature can help you maintain the security of passwords used
on your system.
/TN taskname Specifies the name of the task you want to delete. You can delete all tasks using
the asterisk (*) wildcard.
/F Forces the utility to delete the task and suppress any warnings when the task is currently
running. Use this command line switch only when the task is frozen or unresponsive. Using this
command line switch can result in data loss or other unexpected system behavior.
/Query
The /Queryparameter requests information about any tasks you’ve created. This parameter uses
the following syntax:
SCHTASKS /Query [/S system [/U username [/P password]]]
[/FO format | /XML] [/NH] [/V] [/?] [/TN taskname]
The following list describes each of the command line arguments.
/S system Specifies the remote system that you want to check. In most cases, you’ll also need
to supply the /Uand the /Pcommand line switches when using this switch.
/U [domain\]user Specifies the username on the remote system. This name may not match
the username on the local system. You’ll need to supply a domain name when working with a
domain controller.
/P [password] Specifies the password for the given user. You can provide the command line
switch without specifying the password on the command line in cleartext. The system prompts
you for the password. Using this feature can help you maintain the security of passwords used
on your system.
/FO {TABLE | LIST | CSV} Defines the output provided by the utility. The table format is
normally the easiest to view on screen. The table columns define the values for output, while
each row contains one driver entry. The CSV output provides the best method for preparing the
data for entry in a database. Use redirection (see the “Employing Data Redirection” section of
Chapter 14 for details) to output the CSV data to a file and then import it to your database. The
list format provides one data element per line. Each group of data elements defines one driver.
The utility separates each driver by one blank line. Some people find the list format more readable when working in verbose mode since the table format requires multiple lines for each entry
(the lines wrap).
/XML Displays the output in XML format. This command line switch is useful when you want
to learn more about creating jobs using XML files.
/NH Forces the utility to display the data without a column header. You can only use this
command line switch with the table and CSV formats. Omitting the header makes it easier to
incorporate the data in a report or import it into a database.
/V Displays detailed data about each of the defined tasks. The standard display shows only
TaskName, Next Run Time, and Status. In addition to this basic information, the verbose display
shows HostName, Last Run Time, Last Result, Creator, Schedule, Task To Run, Start In,
Comment, Scheduled Task State, Scheduled Type, Start Time, Start Date, End Date, Days,
SCHEDULING AND MANAGING TASKS 209
Months, Run As User, Delete Task If Not Rescheduled, Stop Task If Runs X Hours and X Mins,
Repeat: Every, Repeat: Until: Time, Repeat: Until: Duration, Repeat: Stop If Still Running, Idle
Time, and Power Management.
/TN taskname Specifies the name of the task you want to query. Vista and above displays all
of the tasks when you don’t supply this parameter.
/Change
The /Changeparameter changes an existing task. You can’t use this parameter to create a new task.
However, this parameter does work well to indicate a change in task location. This parameter uses
the following syntax:
SCHTASKS /Change [/S system [/U username [/P [password]]]] [/RU
runasuser] [/RP runaspassword] [/TR taskrun] /TN taskname [/ST
starttime] [/RI interval] [ {/ET endtime | /DU duration} [/K] ]
[/SD startdate] [/ED enddate] [/ENABLE | /DISABLE] [/IT] [/Z] }
The following list describes each of the command line arguments.
/S system Specifies the remote system that you want to check. In most cases, you’ll also need
to supply the /Uand the /Pcommand line switches when using this switch.
/U [domain\]user Specifies the username on the remote system. This name may not match
the username on the local system. You’ll need to supply a domain name when working with a
domain controller.
/P [password] Specifies the password for the given user. You can provide the command line
switch without specifying the password on the command line in cleartext. The system prompts
you for the password. Using this feature can help you maintain the security of passwords used
on your system.
/RU username Specifies the user account or user context that you want to use to run the task.
Use “”, “NT AUTHORITY\SYSTEM”, or “SYSTEM”to use the system account to run the task.
/RP password Specifies the password of the user account or user context you want to use to
run the task. Use an asterisk (*) or a blank (nothing after the command line switch) in place of
the password when you want the system to prompt you for the password. This command line
switch has no effect when you use the system account to run the task.
/TR taskrun Specifies the full path and filename of the new task that you want to run. The
new task need not be a new execution; it may simply be a new version or a version of the same
executable in a different location. Never assume that the task will run based on a PATH environment variable because you can’t guarantee the user will have the environment variable defined.
You can also specify any command line arguments that the task requires. Enclose tasks with
spaces in quotes.
/TN taskname Specifies the name of the task to change.
/ST starttime Specifies the time that you want the task to run. The time format is
HH:MM:SS (24-hour time). Don’t use a 12-hour time format that includes AM and PM. The
default setting is the current time.
/RI interval Specifies the repetition interval of the task in minutes. You can’t use this
feature with schedule types of MINUTE, HOURLY, ONSTART, ONLOGON, ONIDLE, and
210 CHAPTER 8 PERFORMING TASK AUTOMATION
ONEVENT. The valid range for this argument is 1 to 599,940 minutes. If you specify either the
/ETor /DEcommand line arguments, then the default interval is 10 minutes.
/ET endtime Specifies the end time of the task. The time format is HH:MM:SS (24-hour time).
Don’t use a 12-hour time format that includes AM and PM. You can’t use this feature with
schedule types of ONSTART, ONLOGON, ONIDLE, and ONEVENT. It also isn’t possible to use
this feature with the /DUoption.
/DU duration Specifies the duration of the task. The time format is HH:MM (a time interval
in hours and minutes, not a specific time). You can’t use this feature with schedule types of
ONSTART, ONLOGON, ONIDLE, and ONEVENT. It also isn’t possible to use this feature with
the /EToption. When you specify the /RIargument with a /V1task, the default duration is 1 hour.
/K Automatically terminates the task at the end time or after the duration interval expires. You
can’t use this feature with schedule types of ONSTART, ONLOGON, ONIDLE, and ONEVENT.
This argument is only applicable when you specify either the /ETor /DUcommand line arguments.
/SD startdate Specifies the first date on which to run the task. The date format is mm/dd/
yyyy. Always include a 4-digit year. The default setting is the current day.
/ED enddate Specifies the last date that you want to run the task. The date format is mm/dd/
yyyy. Always include a 4-digit year. The default is not to use an end time, so the task continues
to run indefinitely.
/ENABLE Enables the scheduled task (so it can run).
/DISABLE Disables the schedule task (it can’t run, even when scheduled).
/IT Forces the task to run interactively only. The job runs when the user is logged on, but Vista
and above ignores it when the user is logged out.
/Z Marks the task for deletion after its final run (as specified in the schedule you provide). The
job isn’t actually deleted—Vista and above only marks it for deletion.
/Run
The /Runparameter runs an existing task, even if the task isn’t scheduled to run. Running a task
using this method doesn’t change the task schedule; the task runs using the schedule you set for it.
You can use this feature to test your tasks to ensure they work as anticipated. Check the \Windows\
SchedLgU.TXTfile for the results of any task you run, especially on remote machines. This parameter uses the following syntax:
SCHTASKS /Run [/S system [/U username [/P password]]] /TN taskname
The following list describes each of the command line arguments.
/S system Specifies the remote system that you want to check. In most cases, you’ll also need
to supply the /Uand the /Pcommand line switches when using this switch.
/U [domain\]user Specifies the username on the remote system. This name may not match
the username on the local system. You’ll need to supply a domain name when working with
a domain controller.
/P [password] Specifies the password for the given user. You can provide the command line
switch without specifying the password on the command line in cleartext. The system prompts
you for the password. Using this feature can help you maintain the security of passwords used
on your system.
SCHEDULING AND MANAGING TASKS 211
/TN taskname Specifies the name of the task you want to run. Running a task at the command
line is different from having the Task Scheduler run it for you. Using this option forces the utility
to use your credentials, rather than the Task Scheduler credentials, which means that an executable that normally works could fail when used in this way.
TIP You can use the RunAs utility described in the “Impersonating a User with the RunAs Utility”
section of Chapter 6 to test run a task using another person’s credentials. In fact, you can use this
technique to run the task using the system account. Because people have differing rights, you
need to test the task using the credentials of the person who normally runs it.
/End
The /Endparameter forces a task to stop, even if the task is in the middle of processing data.
Consequently, you should use this parameter with care to avoid data loss or odd system behavior.
You can only use this parameter to end programs started with the Task Scheduler. Use the TaskKill
utility described in the “Terminating Tasks with the TaskKill Command” section of Chapter 21
to end other processes. This parameter uses the following syntax:
SCHTASKS /End [/S system [/U username [/P password]]] /TN taskname
The following list describes each of the command line arguments.
/S system Specifies the remote system that you want to check. In most cases, you’ll also need
to supply the /Uand the /Pcommand line switches when using this switch.
/U [domain\]user Specifies the username on the remote system. This name may not match
the username on the local system. You’ll need to supply a domain name when working with a
domain controller.
/P [password] Specifies the password for the given user. You can provide the command line
switch without specifying the password on the command line in cleartext. The system prompts
you for the password. Using this feature can help you maintain the security of passwords used
on your system.
/TN taskname Specifies the name of the task you want to end.

(C) John Paul Mueller
Administering Windows Server 2008
Server Core
...
Рейтинг: 0 / 0
schtasks
    #38246161
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
неТолик1, а нельзя как-то в одну строку все это написать ? )) сенк
...
Рейтинг: 0 / 0
schtasks
    #38246168
неТолик1
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
_humanнеТолик1, а нельзя как-то в одну строку все это написать ? )) сенк

Вы хотите чтоб за вас написали правило планировщика.
Ставьте задачу + 500 рублёв. Решим.
...
Рейтинг: 0 / 0
schtasks
    #38246369
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
неТолик1,
решать не нужно, просто мануал нужен.
может есть ссылка на форматированный текст ?
...
Рейтинг: 0 / 0
schtasks
    #38246560
неТолик1
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
_humanнеТолик1,
решать не нужно, просто мануал нужен.
может есть ссылка на форматированный текст ?

может гдето и есть ссылка на форматированный текст. если честно я вообще не догоняю про что вы.
мануал я вам дал.
...
Рейтинг: 0 / 0
schtasks
    #38246758
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
неТолик1если честно я вообще не догоняю
создать правило, которое будет запускать приложение спустя 5мин после создания и спустя некоторое время удаляться после завершения(/Z).
...
Рейтинг: 0 / 0
schtasks
    #38246800
Sergey Orlov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
_humanнеТолик1,
решать не нужно, просто мануал нужен.
может есть ссылка на форматированный текст ?
CMD -> schtasks /?
...
Рейтинг: 0 / 0
schtasks
    #38247036
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Sergey Orlov,

да, я читал, но в основном, там примеры с использованием /ST, т.е. с установкой времени. вот. меня интересует текущее время.
я попробовал это сделать в Task Scheduler и тоже не видно, что можно использовать тек.время.
вот что написано
cmd - > schtasks /create /?/ST starttime Specifies the start time to run the task. The time
format is HH:mm (24 hour time) for example, 14:30 for
2:30 PM. Defaults to current time if /ST is not
specified. This option is required with /SC ONCE.
но как пральна использовать не понял.
...
Рейтинг: 0 / 0
schtasks
    #38247070
Sergey Orlov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
_humanSergey Orlov,
да, я читал, но в основном, там примеры с использованием /ST, т.е. с установкой времени. вот. меня интересует текущее время.
я попробовал это сделать в Task Scheduler и тоже не видно, что можно использовать тек.время.
вот что написано
cmd - > schtasks /create /?/ST starttime Specifies the start time to run the task. The time
format is HH:mm (24 hour time) for example, 14:30 for
2:30 PM. Defaults to current time if /ST is not
specified. This option is required with /SC ONCE.
но как пральна использовать не понял.
А *.bat создать никак
@echo off
set /A VMIN=%time:~3,-6%+5
set /A VHOUR=%time:~0,-9%+0
if %VMIN% GTR 59 ( set /a VHOUR=%time:~0,-9%+1)
if %VMIN% GTR 59 ( set /a VMIN=%VMIN%-60)
if %VMIN% LSS 10 ( set VMIN=0%VMIN%)
if %vhour% GTR 23 ( set /a VHOUR=%VHOUR%-24)
if %vhour% LSS 10 ( set VHOUR=0%VHOUR%)
set VStart=%VHOUR%:%VMIN%:00
schtasks /delete /tn StartAfter5 /f
schtasks /create /tn StartAfter5 /tr C:\...\My.bat /sc once /st %VStart% /ru "SYSTEM"

Правда здесь надо доработать ситуацию, когда время переходит на следуюший день ну и здесь запуск для системной учетки...
...
Рейтинг: 0 / 0
schtasks
    #38247136
bazile
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
_human, если есть возможность использовать PowerShell, то лучше именно с её помощью т.к. код яснее будет (взял за основу пример Sergey Orlov):
Код: powershell
1.
2.
3.
4.
5.
[datetime]$d = Get-Date
$d = $d.AddMinutes(5)

.\schtasks /delete /tn StartAfter5 /f
.\schtasks /create /tn StartAfter5 /tr C:\...\My.bat /SC once /ST $d.ToString("hh:mm") /ru "SYSTEM"
...
Рейтинг: 0 / 0
schtasks
    #38247178
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Sergey Orlov,
ухты ! бат скилл + 500 ? +400 к респект. агонь)
то что нужно. переход времени не так важен. я что-то такое и представлял, но думал что можно справиться только с tchtasks. спасибо.
под
Код: powershell
1.
/RU "SYSTEM"

работать не хочет, под тек. пользователем все ок.

bazile,
спасибо.
...
Рейтинг: 0 / 0
schtasks
    #38250933
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
bazile,
PowerShell не хочет работать.
Код: powershell
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
PS E:\doc\bat_tasks> .\task.bat

E:\doc\bat_tasks>[datetime]$d = Get-Date
'[datetime]$d' is not recognized as an internal or external command,
operable program or batch file.

E:\doc\bat_tasks>$d = $d.AddMinutes(5)
'$d' is not recognized as an internal or external command,
operable program or batch file.

E:\doc\bat_tasks>.\schtasks /delete /tn test /f
'.\schtasks' is not recognized as an internal or external command,
operable program or batch file.

E:\doc\bat_tasks>.\schtasks /create /tn test /tr calc.exe /SC once /ST $d.ToString("hh:mm") /ru "SYSTEM"
'.\schtasks' is not recognized as an internal or external command,
operable program or batch file.
PS E:\doc\bat_tasks>
...
Рейтинг: 0 / 0
schtasks
    #38251048
bazile
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
_human, файл должен иметь расширение ps1 и должно быть разрешено выполнение PowerShell скриптов чтобы можно было как bat файл их выполнять.
...
Рейтинг: 0 / 0
schtasks
    #38254023
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
bazile,

Код: powershell
1.
set-executionpolicy remotesigned


Код: powershell
1.
2.
3.
4.
[datetime]$d = Get-Date
$d = $d.AddMinutes(5)
$Command = 'cmd /c "$Env:WinDir/system32/schtasks.exe /create /tn test /tr calc.exe /SC once /ST $d.ToString("hh:mm") /ru SYSTEM"'
Invoke-Expression $Command


но что-то не хочет создаваться задачка.
Код: powershell
1.
2.
3.
PS E:\doc\bat_tasks> .\task.ps1
ERROR: Invalid argument/option - '22:51:52.ToString( hh:mm)'.
Type "SCHTASKS /CREATE /?" for usage.


можно вместо /ST $d.ToString("hh:mm") --> /ST $d . Тогда время будет с секундами.
как передать время в формате hh:mm ?
...
Рейтинг: 0 / 0
schtasks
    #38254073
Фотография zirra
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
"_human" <nospam@sql.ru>; wrote in message news:14283053@sql.ru...
_humanbazile,
PS E:\doc\bat_tasks> .\task.ps1
ERROR: Invalid argument/option - '22:51:52.ToString( hh:mm)'.
Может поможет:
Код: sql
1.
$LogTime=([System.DateTime]::Now).ToString("dd-MM-yyyy hh:mm:ss") 


--
Vladimir A.Bakhvaloff E-Mail:bob<bark>bakh<dot>spb<dot>ru

Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
schtasks
    #38254165
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
zirra, да это оно.
ток вот теперь проблема с пробелами в путях - c:\program files\...exe .
Как указать путь и параметр к нему ? а то и так кавычек хватает всяких. а тут..
Код: powershell
1.
2.
3.
4.
5.
[datetime]$d = Get-Date
$d = $d.AddMinutes(5)
$LogTime=$d.ToString("hh:mm") 
$Command = 'cmd /c "$Env:WinDir/system32/schtasks.exe /create /tn test /tr 'C:\Program Files\Windows Media Player\wmplayer.exe' /SC once /ST $LogTime /ru WindofChange"'
Invoke-Expression $Command
...
Рейтинг: 0 / 0
schtasks
    #38254208
Фотография zirra
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
"_human" <nospam@sql.ru>; wrote in message news:14283495@sql.ru...
_humanток вот теперь проблема с пробелами в путях - c:\program files\...exe.
М-м-м... Я же не настоящий сварщик, дядя... :) У меня даже PowerShell не запускается... ;)
Но, имхо, надо как-то так:
Код: sql
1.
2.
$Command = 'cmd /c $Env:WinDir/system32/schtasks.exe /create /tn test /tr "C:\Program Files\Windows Media Player\wmplayer.exe" 
/SC once /ST $LogTime /ru WindofChange'


Или вообще - взять короткий путь: C:\PROGRA~1\WI54FB~1\wmplayer.exe (у тебя, скорее всего, другое что-то)...

--
Vladimir A.Bakhvaloff E-Mail:bob<bark>bakh<dot>spb<dot>ru

Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
schtasks
    #38254239
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
zirra, нет. что не так. используется только часть строки - все что слева от пробела.
РОЗЫСК: сварщик 12 разряда.
...
Рейтинг: 0 / 0
schtasks
    #38254251
Фотография zirra
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
"_human" <nospam@sql.ru>; wrote in message news:14283669@sql.ru...
_humanzirra, нет. что не так. используется только часть строки - все что слева от пробела.
Дык, а если кавычки вернуть на место, но использовать КОРОТКИЙ путь?..

--
Vladimir A.Bakhvaloff E-Mail:bob<bark>bakh<dot>spb<dot>ru

Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
schtasks
    #38254262
Фотография С0ВЕСТЬ
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
schtasks
    #38254274
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
zirra, как узнать короткий путь ? или "/6 первых сиволов"+"~1/" ?
для параметров также используется короткий путь ? но вроде между ними тоже пробел)
С0ВЕСТЬ http://www.nncron.ru/index_ru.shtml
в описании написано круто. посмотрю. сенк.
...
Рейтинг: 0 / 0
schtasks
    #38254278
Фотография zirra
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
"_human" <nospam@sql.ru>; wrote in message news:14283800@sql.ru...
_humanzirra, как узнать короткий путь ? или "/6 первых сиволов"+"~1/" ?
Берёшь FAR, ставишь на имя нужного файла, Ctrl-N, Ctrl-F, Ctrl-F, Ctrl-Insert...
--
Vladimir A.Bakhvaloff E-Mail:bob<bark>bakh<dot>spb<dot>ru

Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
schtasks
    #38254281
Фотография zirra
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
"zirra" <nospam@sql.ru>; wrote in message news:14283814@sql.ru...
Берёшь FAR, ставишь на имя нужного файла, Ctrl-N, Ctrl-F, Ctrl-F, Ctrl-Insert...
Извиняюсь, слажал...
Ctrl-N, Ctrl-F, Ctrl-N, Ctrl-Insert - и в клипборде короткий путь...

--
Vladimir A.Bakhvaloff E-Mail:bob<bark>bakh<dot>spb<dot>ru

Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
schtasks
    #38254394
_human
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
zirra , это сплошной *рукалицо*.
походу вот это
Код: powershell
1.
2.
3.
[datetime]$d = Get-Date
$d = $d.AddMinutes(5)
$LogTime=$d.ToString("hh:mm") 

делает дату в формате AM-PM. Но schtasks работает с временем формата 24 часа.
авторCtrl-N, Ctrl-F, Ctrl-N, Ctrl-Insert
получилось, только с Ctrl+[ :)
пока не получилось с короткими путями.

С0ВЕСТЬ , можно ли nnCron с консоли работать ? в хелпе не нашел.
ps win7
...
Рейтинг: 0 / 0
schtasks
    #38254413
Фотография zirra
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
"_human" <nospam@sql.ru>; wrote in message news:14284166@sql.ru...
_human$LogTime=$d.ToString("hh:mm")
делает дату в формате AM-PM. Но schtasks работает с временем формата 24 часа.
.ToString('HH:mm')
_humanполучилось, только с Ctrl+[ :)
Странно... У меня всё работает, как я и сказал...
_humanС0ВЕСТЬ, можно ли nnCron с консоли работать ? в хелпе не нашел.
У него есть конфиг, который можно в консоли редактировать... %)))
--
Vladimir A.Bakhvaloff E-Mail:bob<bark>bakh<dot>spb<dot>ru

Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
26 сообщений из 26, показаны все 2 страниц
Форумы / Windows [игнор отключен] [закрыт для гостей] / schtasks
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]