0

This is the script I am trying to execute:

(netsh wlan show profiles) | Select-String "\:(.+)$" | %    {$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize

Which is stored in a file "NetGrabber.ps1" and I want to execute it in C++, I would like to use the file but I can hard code it too if that's easier. And my code I have so far, I just want it to be run in a case statement just like

Case 1:
    Execute();
    break;

WinExec is for exe and batch files as far as I'm concerned.

Logan
  • 51
  • 10
  • 2
    `powershell -File "C:\Path\script.ps1"` - but, as a warning, be aware of where your scripts 'expect' you to be prior to running. Some slight script modifications (or different parameter calls of PowerShell) would help. – gravity Jul 08 '16 at 13:21
  • Possible duplicate of [How to call an external program with parameters?](http://stackoverflow.com/questions/486087/how-to-call-an-external-program-with-parameters) – gravity Jul 08 '16 at 13:59
  • I'm confident that the [linked question](http://stackoverflow.com/questions/486087/how-to-call-an-external-program-with-parameters) has an [answer here](http://stackoverflow.com/a/486409/2486496) in conjunction with my comment above. – gravity Jul 08 '16 at 14:00
  • The link did not help, and for your first comment, that helped but now i get an error that my computer cannot run scripts – Logan Jul 08 '16 at 21:57

0 Answers0