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.

4
  • 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. Commented Jul 8, 2016 at 13:21
  • Possible duplicate of How to call an external program with parameters? Commented Jul 8, 2016 at 13:59
  • I'm confident that the linked question has an answer here in conjunction with my comment above. Commented Jul 8, 2016 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 Commented Jul 8, 2016 at 21:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.