China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-07 12:59
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Solved] Get the current system time with VBS and add an at task View 2,875 Replies 27
Original Poster Posted 2008-01-26 06:04 ·  中国 湖南 常德 电信
中级用户
★★
Credits 231
Posts 102
Joined 2008-01-25 23:45
18-year member
UID 109557
Gender Male
Status Offline
For example, now a VBS script runs. Before exiting this script (because there is a do loop statement before, so it will not exit automatically after running). Get the current system time. Just get the minutes. Then add 5 minutes to the obtained current time, and then run this VBS script. Simply put, it is like at the current system time (minutes) +5 (minutes) xx.vbs wscript.quit

[ Last edited by hackhd on 2008-1-27 at 07:24 PM ]
Floor 2 Posted 2008-01-26 12:28 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
msgbox time自己mid吧
Floor 3 Posted 2008-01-26 18:37 ·  中国 湖南 常德 电信
中级用户
★★
Credits 231
Posts 102
Joined 2008-01-25 23:45
18-year member
UID 109557
Gender Male
Status Offline
Floor 4 Posted 2008-01-26 19:07 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
```
Times = Time
NewTime = Split(times, ":", -1)
Wscript.echo NewTime(1) + 5
'Full writing
Wscript.echo Time & "====Add 5 minutes is====" & NewTime(0) & chr(58) & NewTime(1) + 5 & chr(58) & NewTime(2)
```
第一高手 第二高手

Floor 5 Posted 2008-01-26 19:30 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
The last sentence above is Times
Floor 6 Posted 2008-01-26 19:31 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
It seems that the 55 processing was not done...
Floor 7 Posted 2008-01-26 19:57 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Yes, in fact, the first sentence is redundant and not processed for 55+. I was afraid of numerical calculations
NewTime = Split(time, ":" ,-1)
Wscript.echo NewTime(1)+5
Wscript.echo Time & "====加5 minutes is====" & NewTime(0) & chr(58) & NewTime(1)+5 & chr(58) & NewTime(2)
第一高手 第二高手

Floor 8 Posted 2008-01-26 19:58 ·  中国 湖南 常德 电信
中级用户
★★
Credits 231
Posts 102
Joined 2008-01-25 23:45
18-year member
UID 109557
Gender Male
Status Offline
The method of getting time is clearly stated on the 4th floor. Thanks. But why do I get an error when I integrate it and add a DOS task.
dim wsh
set wsh=createobject("wscript.shell")
set fso=createobject("scripting.filesystemobject")
Times = Time
NewTime = Split(times, ":" ,-1)
command="at "&NewTime&"(1)+5 "&"1.vbs"
retodate=wsh.Run(command,0,true)
Floor 9 Posted 2008-01-26 20:03 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Then msgbox your command and you'll know where you're wrong.
Floor 10 Posted 2008-01-26 20:12 ·  中国 湖南 常德 电信
中级用户
★★
Credits 231
Posts 102
Joined 2008-01-25 23:45
18-year member
UID 109557
Gender Male
Status Offline
Now it has prompted that the type of the command line does not match. Adding msgbox later doesn't work. I'm a newbie, and I'm bothering the elder brother to give more guidance.
Floor 11 Posted 2008-01-26 20:22 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
command = "at " & NewTime & "(1)+5 " & "1.vbs"

You follow the modification of floor 4...

NewTime is an array...

Cannot be single, your parenthesis reference is wrong...
Floor 12 Posted 2008-01-26 21:04 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Here is the translation:


NewTime = Split(Time, ":", -1)
If NewTime(1) + 5 > 59 Then
mm = NewTime(1) + 5 - 60
Newnn = Split(NewTime(0), " ", -1)
If Newnn(1) + 1 = 13 Then
nn = "01"
Else
nn = Newnn(1) + 1
End If
Times = Newnn(0) & " " & nn & Chr(58) & mm & Chr(58) & NewTime(2)
Else
Times = NewTime(0) & ":" & NewTime(1) + 5 & ":" & NewTime(2)
End If
Wscript.Echo Time & "====Add 5 minutes is====" & Times
第一高手 第二高手

Floor 13 Posted 2008-01-26 21:23 ·  中国 湖南 常德 电信
中级用户
★★
Credits 231
Posts 102
Joined 2008-01-25 23:45
18-year member
UID 109557
Gender Male
Status Offline
Wow. So much code. What if it's a virus? Just one function takes up so much.

a=Wsh.Run("at " & hour(now) & ":" & ((minute(now)+5) mod 60) & " 1.vbs",0,False)

[ Last edited by hackhd on 2008-1-26 at 09:41 PM ]
Floor 14 Posted 2008-01-26 21:32 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Newnn = Split(NewTime(0), " " ,-1) 'I don't know the intention

'Splitting time gets hours, minutes and seconds...

What you did above seems to have subscript out of bounds...
Floor 15 Posted 2008-01-26 21:34 ·  中国 陕西 西安 电信
铂金会员
★★★★
Credits 5,212
Posts 2,478
Joined 2007-02-08 23:39
19-year member
UID 79003
Gender Male
Status Offline
Originally posted by hackhd at 2008-1-26 21:23:
Wow. So much code. What if it's a virus? Just one function takes up so much.

a=Wsh.Run("at "&hour(now)&":"&(minute(now)+5)&" 1.vbs",0,False)


It's not about the length to determine the quality of code absolutely...

Do you think this one is good?

What's your result at 12:56:36? And using at like this may not work.
Forum Jump: