Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Open Powershell Script with AHK


Best Answer Jackie Sztuk _Blackholyman , 08 July 2015 - 08:16 AM

Go to the full post »


  • Please log in to reply
6 replies to this topic
Gater
  • Members
  • 6 posts
  • Last active: Jul 13 2015 03:30 PM
  • Joined: 06 Jul 2015

Is it possible to open and run a Powershell script from AHK? Does anyone have any ideas of what that AHK script would look like?



Shadowpheonix
  • Members
  • 268 posts
  • Last active:
  • Joined: 10 Feb 2014

Sure.  If your PowerShell script is "MyScript.ps1" located in "C:\", then...[/code]

run c:\MyScript.ps1

[/code]



Gater
  • Members
  • 6 posts
  • Last active: Jul 13 2015 03:30 PM
  • Joined: 06 Jul 2015

Sure.  If your PowerShell script is "MyScript.ps1" located in "C:\", then...[/code]

run c:\MyScript.ps1

[/code]

This doesn't seem to work. I think the AHK script needs to open Powershell then type in Powershell to have it run this script. Do you know how to do that? Sorry, I know so little about writing AHK scripts.



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
✓  Best Answer
Try it like this
psScript := "c:\MyScript.ps1"
Run, powershell.exe "%psScript%"

Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

Gater
  • Members
  • 6 posts
  • Last active: Jul 13 2015 03:30 PM
  • Joined: 06 Jul 2015

Try it like this

psScript := "c:\MyScript.ps1"
Run, powershell.exe "%psScript%"

Strange. It just seems to open then instantly close Powershell. 



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012

then try with RunWait and make the script #Persistent


Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

Gater
  • Members
  • 6 posts
  • Last active: Jul 13 2015 03:30 PM
  • Joined: 06 Jul 2015

I pointed the AHK script to use Powershell-ISE and that worked. Thanks for all the help!