Hi to all,
can you please help me with this issue.
My intention is to use rsp probe to check (with lua script) if a file exists on system, the version of file and when it was last modified. I have also tried to use dirscan but it doesn't provide all informations and tried to use rsp with WMI but it doesn't read (load) any instance in CIM_DataFile class My plan was to use powershell but i stumbled on problem that it is just not possible to run powershell command from LUA. I have tried few different approaches:
1.
function tprint (t, s)
for k, v in pairs(t) do
local kfmt = '["' .. tostring(k) ..'"]'
if type(k) ~= 'string' then
kfmt = '[' .. k .. ']'
end
local vfmt = '"'.. tostring(v) ..'"'
if type(v) == 'table' then
tprint(v, (s or '')..kfmt)
else
if type(v) ~= 'string' then
vfmt = tostring(v)
end
print((s or '')..kfmt..' = '..vfmt)
end
end
end
a=action.command ("powershell.exe -Command (Get-Item 'C:\Windows\System32\notepad.exe').VersionInfo.FileVersion")
tprint(a)
2.
function cmdout(cmd)
local f = io.popen(cmd)
local lout = f:read("*a")
f:close()
return lout
end
cmd = "powershell.exe -Command '(Get-Item 'C:\Windows\System32\notepad.exe').VersionInfo.FileVersion'"
lout = cmdout(cmd)
print(lout)
3.
n = os.tmpname ()
os.execute ("powershell.exe -Command "(Get-Item 'C:\Windows\System32\notepad.exe').VersionInfo.FileVersion" > " .. n)
for line in io.lines (n) do
print (line)
end
os.remove (n)
Thank you