中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-11-11 14:32
47,815 topics / 349,930 posts / today 0 new / 48,291 members
DOS批处理 & 脚本技术(批处理室) » [Solved] Get the current system time with VBS and add an at task
Printable Version  3,589 / 27
Floor16 hackhd Posted 2008-01-26 21:41
中级用户 Posts 102 Credits 231
It has been considered.

So.


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

Problem solved
Floor17 fastslz Posted 2008-01-26 21:44
铂金会员 Posts 2,315 Credits 5,493 From 上海
Forget it, just give you the code. AT doesn't support AM/PM, and it also needs to format it in 24-hour format.
Floor18 fastslz Posted 2008-01-26 21:54
铂金会员 Posts 2,315 Credits 5,493 From 上海
hour(now)&":"&((minute(now)+5) mod 60
Floor19 slore Posted 2008-01-26 22:35
铂金会员 Posts 2,478 Credits 5,212
f
Newnn = Split(NewTime(0), " ", -1)
Is this working for you?

h?
Did you consider that? You'll have to wait a whole day for it to run like that?

12:56 + 5 = 13:01

Running it at 12:01 like that... that's called considering...
Floor20 fastslz Posted 2008-01-26 22:59
铂金会员 Posts 2,315 Credits 5,493 From 上海
Newnn = Split(NewTime(0), " ", -1)
if Newnn(1) + 1 = 13 Then
nn = "01"
else
nn = Newnn(1) + 1
end if
Has been converted
Floor21 slore Posted 2008-01-26 23:02
铂金会员 Posts 2,478 Credits 5,212
The "NewTime(0)" does not contain spaces... What do you mean by that? After splitting by spaces, newnn(1) does not exist... Then you will have a subscript out of bounds...

The first time you split time, 0, 1, 2 are h, m, s respectively
Floor22 fastslz Posted 2008-01-26 23:14
铂金会员 Posts 2,315 Credits 5,493 From 上海
Wscript.echo Time
Afternoon space HH:MM:SS

TimeTmp="Afternoon 12:56:00"
NewTime = Split(TimeTmp, ":" ,-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) & chr(58) & NewTime(1)+5 & chr(58) & NewTime(2)
end if
Wscript.echo Times
Wscript.echo FormatDateTime (Times ,vbShortTime)
Floor23 fastslz Posted 2008-01-26 23:19
铂金会员 Posts 2,315 Credits 5,493 From 上海
Discussing which of the two codes can achieve the LZ's purpose is meaningless.
Floor24 slore Posted 2008-01-26 23:22
铂金会员 Posts 2,478 Credits 5,212
Originally posted by fastslz at 2008-1-26 23:19:
The discussion about the two types of code achieving the LZ's purpose is meaningless



......It means that when the system selects the 24-hour system, the word "afternoon" will not appear...
The portability of this code...

His code does not do carry although it is one sentence...

I mean this problem... has nothing to do with the method.
Floor25 hackhd Posted 2008-01-26 23:27
中级用户 Posts 102 Credits 231
Oh yeah. The discussion is really intense. Of course my sentence is just to achieve my purpose, because I don't need the judgment of morning and afternoon, just let the system add 5 to the time.

What everyone discussed is also right. It's another train of thought

No matter what method, I just hope the code can be as concise as possible

[ Last edited by hackhd on 2008-1-26 at 11:29 PM ]
Floor26 zh159 Posted 2008-01-27 01:14
金牌会员 Posts 1,467 Credits 3,687
Just one DateAdd
Floor27 fastslz Posted 2008-01-27 14:35
铂金会员 Posts 2,315 Credits 5,493 From 上海
Oh, the DateAdd function is actually so simple. I overcomplicated it before. Vbs time conversion is too flexible. If one has a good command of English in writing vbs scripts, it's like writing short sentences. The reason why the Chinese software industry is not as good as the later - catching - up India is also because of the language barrier of localization.
Floor28 hackhd Posted 2008-01-27 19:07
中级用户 Posts 102 Credits 231
Wsh.Run "at " & hour(now) & ":" & ((minute(now) + 5) mod 60) & " 1.vbs", 0, False
FormatDateTime(DateAdd("n", 5, now), vbShortTime)
It's also good.
Prev  1 2
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023