Godot Version
4.4.1
Question
I am making a software launcher, and for that I want to check the version of a file, and since Godot doesn’t have a way to do that natively I need to make platform-specific commands, for Windows I have the following;
# 'location' is the absolute path of the executable
var cmd : String = ("get-ciminstance -Query %1Select * from CIM_DataFile WHERE Name=%2" + location.replace("\\", "\\\\") + "%2%1 | Select Version").replace("%1", '"').replace("%2", "'")
I know this command works as I can run it myself and it works fine;
(Using another software I released to test, and it gives the correct output)
But when trying to run in Godot it throws up an error for not understanding the ‘*’ for selecting all;
var out : Array[Variant]
var cmd : String = ("get-ciminstance -Query %1Select * from CIM_DataFile WHERE Name=%2" + location.replace("\\", "\\\\") + "%2%1 | Select Version").replace("%1", '"').replace("%2", "'")
print(cmd)
print(OS.execute("powershell.exe", ["-Command", cmd], out, true))
print(out)
Above prints (For this ‘location’ is the same as what I used when running the command myself);
# get-ciminstance -Query "Select * from CIM_DataFile WHERE Name='E:\\Music\\Software\\NatMusicProgramme.exe'" | Select Version
# 1
# ["
# Get-CimInstance : A positional parameter cannot be found that accepts argument '*'.
# At line:1 char:1
# + get-ciminstance -Query Select * from CIM_DataFile WHERE Name='E:\\Mus ...
# + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# + CategoryInfo : InvalidArgument: (:) [Get-CimInstance], ParameterBindingException
# + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand
# "]
I don’t understand this as the command does work, it can accept ‘*’ as an argument when I run it, but when Godot runs it then it can’t use ‘*’ anymore? I have been at this for hours even trying to use OS.execute_with_pipe()
but have got nowhere.
Thanks.