- K.O.
import clr, time, sys
sys.stdout.write( "Computer Name or IP:")
computername = sys.stdin.readline().replace("\n","")
sys.stdout.write( "Login name:")
username = sys.stdin.readline().replace("\n","")
sys.stdout.write( "Password:")
password = sys.stdin.readline().replace("\n","")
clr.AddReference("System.Management")
from System.Management import *
connOpts = ConnectionOptions()
connOpts.Username = username
connOpts.Password = password
scope = ManagementScope("\\\\" + computername + "\\root\\cimv2", connOpts)
scope.Connect()
query = ManagementObjectSearcher("Select * from win32_OperatingSystem")
query.Scope = scope
for result in query.Get():
strTime = time.strptime(result.GetPropertyValue("LocalDateTime")[0:14],"%Y%m%d%H%M%S")
print time.strftime("%Y/%m/%d %H:%M:%S",strTime)
No comments:
Post a Comment