am preparing a long script to retrieve the LAPS password in to a variable and print it to a msgbox. i have this nice script that do the job silently and print the result to msgbox perfectly. however, when i replaced the server name by the variable %VAR% which i set it before its not working and shows nothing. its only work if i mention the computer name as string but not as %VAR% variable! i think the %VAR% is not replaced or passed to that command for some reason.
can any one advice?
Code: Select all
DetectHiddenWindows On
VAR = exampleServerNEW
Run %ComSpec%,, Hide, pid
WinWait ahk_pid %pid%
DllCall("AttachConsole", "UInt", pid)
WshShell := ComObjCreate("Wscript.Shell")
exec := WshShell.Exec("powershell.exe -command ""Get-AdmPwdPassword -ComputerName %VAR% | foreach { $_.Password }""")
output := exec.StdOut.ReadAll()
MsgBox %output%
DllCall("FreeConsole")
Process Close, %pid%
return