I'm trying to execute a hidden process to retrieve the output.
For this task I'm trying to use Exec method but the problem that I see is that I can't hide the process window?.
I've seen an alternative way using Run method to start the process hidden, and then writting the output to a textfile, and then parsing the text content, but that It's not what I'm looking for 'cause I always try to avoid bad programming practices in other languages so I would like to know if this operation in VBS can be performed without managing the creation of external text files, just I want to simplify things and don't create textfiles.
Here is my code:
Response = CreateObject("WScript.Shell"). _
Exec("powercfg.exe /GetActiveScheme"). _
StdOut.ReadAll
PowerPlanName = Split(Split(Response, "(")(1), ")")(0)
PowerPlanGUID = Split(Split(Response, ":")(1))(1)
Msgbox "Information about the current energy scheme." & vbNewLine & vbNewLine & _
"Name: " & PowerPlanName & vbNewLine & _
"GUID: " & PowerPlanGUID, _
64, _
"Energy scheme (powercfg.exe)"
WScript.Quit(0)