答案 0 :(得分:1)
我忘记了我的旧登录信息,所以我没有足够的代表对现有的回复发表评论,所以我在这里发表评论。
思想1:我在16年前写了一篇关于云雀的剧本。哇,它仍然存在。
思想2:我很欣赏Sushi博士的链接和信誉。
思想3:不幸的是,链接实际上被嵌入式空间破坏了。所以"来自评论"的观点也很好。 (我发现此页面在我的分析中追踪了404s :)这是一个更好的/父级链接,它提供了上下文:http://slingfive.com/pages/code/bgInfo_scripts/
最后,为了涵盖所有基础,这里也是完整代码的粘贴:
'<script language="vbscript">
OPTION EXPLICIT
DIM oNet, strComputerName, strUserName, strUserDomain
SET oNet = CreateObject("WScript.Network")
strComputerName = oNet.Computername
strUserName = oNet.UserName
strUserDomain = oNet.UserDomain
'msgbox strUserDomain
SET oNet = nothing
DIM oUser, strReturn
on error resume next
SET oUser = GetObject("WinNT://" & fnGetWorkgroupName(".") & "/" & strComputerName & "/" & strUserName & ",user")
strReturn = oUser.LastLogin
on error goto 0
SET oUser = nothing
IF isDate(strReturn) THEN
strReturn = cdate(strReturn)
strReturn = Replace(strReturn, ":" & Right(0 & Second(strReturn), 2) & " ", "") 'drop seconds
END IF
On Error Resume Next
call WScript.Echo(strReturn) 'for cmd line
call Echo(strReturn) 'for BGInfo
on error goto 0
' gets current workgroup
' params: computer name (can take "." for current computer instead)
' returns: string of computer's current workgroup
FUNCTION fnGetWorkgroupName(p_strComputer)
DIM colItems, oItem
Set colItems = GetObject("winmgmts:\\" & p_strComputer & "\root\cimv2").ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each oItem in colItems
fnGetWorkgroupName = oItem.Domain
Next
SET colItems = nothing
END FUNCTION
答案 1 :(得分:-1)
似乎BGInfo无法解析上次登录时间,当用户从重新启动或解锁屏幕登录时它会丢失,因此正确答案是查询信息的VBScript。
http://slingfive.com/pages/code/bgInfo_scripts/scripts/getCu%20rrentUserLastLoginTime.vbs