Basis windows shell coding

Windows2012发布后,未来也许就是通过Shell去管理Windows了,因此最近着迷windows shell和power shell,coding来自《Windows脚本编程核心技术精解》



yourself = "What's your birthday"

yourage = "Let's see how old you are"


do
birthday = InputBox(yourself,yourage)
'check whether the user wants to quit:
if isEmpty(birthday) then
MsgBox "Hey! you could always lie to me to hide" & "your age! but ok. i quit!"
WScript.Quit
elseif not isDate(birthday) then
'check whether birther is ceally a date
'complain and give another chance:
MsgBox "You didn't enter a valid date! Try again"
end if
'loop untile a valid date was retrieved
loop until isDate(birthday)

age_in_days = DateDiff("d",birthday,date)
age_in_months = DateDiff("m",birthday,date)
age_in_years = DateDiff("yyyy",birthday,date)
day_born = WeekdayName(Weekday(birthday))

date_day = Day(birthday)
date_month = Month(birthday)

date_year = Year(date)
this_years_birthday = DateSerial(date_year,date_month,date_day)

days_to_birthday = Abs(DateDiff("d",date,this_years_birthday))
day_celebrating = WeekdayName(Weekday(this_years_birthday))

if this_years_birthday < date then
message = "you celebrated your birthday"  & days_to_birthday & " days ago"
elseif this_years_birthday = date then
message = "Hayyp Birthday!!!"
else
message = days_to_birthday & "days to go !"
end if

msg = "This is your birthday analysis:" & vbCr
MsgBox (msg)
msg = msg + "You are born on " & birthday & vbCr
MsgBox (msg)
msg = msg + "You are " & age_in_years & " yrs old. that's " & vbCr
MsgBox (msg)
msg = msg & age_in_months & "months or " & age_in_days & " days! " &vbCr
MsgBox (msg)
msg = msg + " You were born on a " & day_born & cbCr
MsgBox (msg)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值