Вверх ↑
Ответов: 48
Рейтинг: 0
#1: 2006-12-04 07:56:41 ЛС | профиль | цитата
tsdima, Еще раз повторяю, что мне не нужен планировщик! Мне нужно написать собственный сервис, а как управляться с планировщиком я сам могу научить кого угодно :-P

sCommand = "Notepad.exe"
sComputer = "MyComp"
set oShell = wscript.createobject("wscript.shell")
sTime = Hour(Time) & ":" & Minute(Time)+2
sCommand = "at \\" & sComputer & " " & sTime & " """ & sCommand & """"
oShell.Run sCommand
или
'==== Script Information Header ====
'script name:	AT-Command_wmi.vbs
'date: 04.11.06
'autor: Bochkarev Vitaly
'description: Создает задание на удаленном компьютере на запуск указанной команды через 2 минуты от текущего времени
'==== Script Main Logic ====
'Creating command line
sCommand = "Notepad.exe"
'Entering a computer name
sComputer = Inputbox ("Введите имя компьютера на который необходимо установить программу",_
[tab]"Удаленная установка программы","BOR0000")
if sComputer = "" or sComputer = "BOR0000" then
wscript.echo "Computer name is not correct"
wscript.quit
end if
' Connecting to remote computer Windows Management Instrumentarium service
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
' Connecting to TimeZone object
set oColTime = oWMIService.ExecQuery("Select * from Win32_TimeZone")
' Getting information about selected time zone on the computer
For Each item In oColTime
iLocalBias = item.Bias
Next
'Making Start time for the job: "YYYYMMDDHHMMSS.MMMMMM(+-)OOO"
' Creating OOO
select case Len(cStr(Abs(iLocalBias)))
case "0"
wscript.echo "Error! No information about remote computer time settings."
wscript.quit
case "1"
sLocalBias = "00" & cStr(Abs(iLocalBias))
case "2"
sLocalBias = "0" & cStr(Abs(iLocalBias))
case else
sLocalBias = cStr(Abs(iLocalBias))
end select
' Creating (+-)OOO
if iLocalBias >= 0 then
sOOO = "+" & sLocalBias
else
sOOO = "-" & sLocalBias
end if
' Creating YYYYYMMDDHHMMSS.MMMMMM (2 minutes to delay the task)
if Len(cStr((Minute(Time) + 2))) = 1 then
sMM = "0" & cStr(Minute(Time) + 2)
else
sMM = cStr(Minute(Time) + 2)
end if
if Len(cStr(Hour(Time))) = 1 then
sHH = "0" & cStr(Hour(Time))
else
sHH = cStr(Hour(Time))
end if
sYYYYYMMHHMMSS = "********" & sHH & sMM & "00.000000"
' Creating start time
sStartTime = sYYYYYMMHHMMSS & sOOO
' Connecting to ScheduledJob object
Set oJob = oWMIService.Get("Win32_ScheduledJob")
'Setting the task
errJobCreated = objNewJob.Create (sCommand, sStartTime, False , , , False, JobID)
'help for method Create(Command, Time, RunRepeatedly, DaysOfWeek to run, DaysOfMonth to run, InteractWithDesktop, JobID)
if errJobCreated = 0 then
Wscript.Echo "The job was successfully set on " & sComputer
else
Wscript.Echo "Error! The job has not been set."
end if
карма: 0

0