Variables in powershell

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tassman
Posts: 6
Joined: 28 Sep 2016, 01:12

Variables in powershell

10 May 2021, 02:02

Got command:

Code: Select all

idtoUpdate = 2
diskLetter := ComObjCreate("WScript.Shell").Exec("powershell Get-Disk idtoUpdate | Get-Partition | Select-Object DriveLetter | Format-Custom").StdOut.ReadAll()
After execute nothing happens. Of course command working if there is proper number -

Code: Select all

diskLetter := ComObjCreate("WScript.Shell").Exec("powershell Get-Disk 2 | Get-Partition | Select-Object DriveLetter | Format-Custom").StdOut.ReadAll()
I think there is problem with quotes or escaping. Help please.
tassman
Posts: 6
Joined: 28 Sep 2016, 01:12

Re: Variables in powershell

10 May 2021, 02:11

Got it. Should be quoted and spaced.

Code: Select all

diskLetter := ComObjCreate("WScript.Shell").Exec("powershell Get-Disk " idtoUpdate " | Get-Partition | Select-Object DriveLetter | Format-Custom").StdOut.ReadAll()

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 136 guests