I'm trying to develop a VB.NET software that runs the following code in PowerShell:
Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
I've already created a .ps1 file, inserting this code and calling it in VisualStudio:
Shell("powershell -noexit Start-Process powershell -Verb runAs ""C:\Users\netov\Desktop\teste.ps1""", AppWinStyle.NormalFocus, True)
It runs, calls the PowerShell as Administrator, but I got the erro showing that The execution scripts was disabled in this system and said to check about about_Execution_Policies
I googled and I've found that if I run Set-ExecutionPolicy Unrestricted
in PowerShell it allows me (after press Y to yes) runs the scripts.
The issue is I cannot run that code above into VS. I tried to add this Set-ExecutionPolicy Unrestricted
in my file Teste.ps1, but didn't work out.
Someone already had this problem? Or if has another way to make that.
I'm trying to make it, because the Start Button in some computers with Windows 10 stops working. So I've thought in create a software to help some users.