-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem info.lua
94 lines (76 loc) · 2.72 KB
/
system info.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
function executeCommand(command)
handle = io.popen(command)
if handle then
result = handle:read("*a")
handle:close()
return result
else
return nil
end
end
function removeEmptyLines(text)
lines = {}
for line in text:gmatch("[^\r\n]+") do
if line:match("%S") then -- Check if the line contains non-whitespace characters
table.insert(lines, line)
end
end
return table.concat(lines, "\n")
end
function getSystemUUID()
uuidCommand = 'wmic csproduct get uuid'
uuidInfo = executeCommand(uuidCommand)
uuid = uuidInfo and uuidInfo:match("{.-}") or "UUID not found"
return uuid
end
function getMACAddress()
macCommand = 'ipconfig /all'
macInfo = executeCommand(macCommand)
mac = macInfo and macInfo:match("Physical Address[%.:%s]+([%x%-]+)") or "MAC Address not found"
return mac
end
function getIPAddress()
ipCommand = 'ipconfig'
ipInfo = executeCommand(ipCommand)
ip = ipInfo and ipInfo:match("IPv4 Address[%.:%s]+([%d%.]+)") or "IP Address not found"
return ip
end
function getSystemInfo()
systemInfoCommand = 'systeminfo'
systemInfo = executeCommand(systemInfoCommand)
return systemInfo or "System information not found"
end
function getHardwareInfo()
hardwareInfoCommand = 'wmic cpu get Name /format:list && wmic memorychip get Capacity /format:list && wmic diskdrive get Model,Size /format:list'
hardwareInfo = executeCommand(hardwareInfoCommand)
return hardwareInfo or "Hardware information not found"
end
function getUserInfo()
userInfoCommand = 'net user %username%'
userInfo = executeCommand(userInfoCommand)
return userInfo or "User information not found"
end
function getInstalledSoftware()
softwareInfoCommand = 'wmic product get Name,Version'
softwareInfo = executeCommand(softwareInfoCommand)
return softwareInfo or "Installed software information not found"
end
function saveSystemInfoToFile()
file = io.open("C:\\Windows\\Temp\\system_info.txt", "w")
file:write("System UUID:\n")
file:write(removeEmptyLines(getSystemUUID()).."\n\n")
file:write("MAC Address:\n")
file:write(removeEmptyLines(getMACAddress()).."\n\n")
file:write("IP Address:\n")
file:write(removeEmptyLines(getIPAddress()).."\n\n")
file:write("System Information:\n")
file:write(removeEmptyLines(getSystemInfo()).."\n\n")
file:write("Hardware Information:\n")
file:write(removeEmptyLines(getHardwareInfo()).."\n\n")
file:write("User Information:\n")
file:write(removeEmptyLines(getUserInfo()).."\n\n")
file:write("Installed Software:\n")
file:write(removeEmptyLines(getInstalledSoftware()).."\n\n")
file:close()
end
saveSystemInfoToFile()