I wrote a PowerShell script to give run access to run without admin privilege. So I need to run that script from batch file. Here I attached my PowerShell script and my batch file. I am not able to run the PowerShell script from my batch file.
Access.ps1
powershell -File "%~dpn0.ps1" %*
Start-Process PowerShell -ArgumentList "Set-ExecutionPolicy Unrestricted -Force" -Verb RunAs
$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SOFTWARE\Wow6432Node\Unicorn",[Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree,[System.Security.AccessControl.RegistryRights]::ChangePermissions)
$acl = $key.GetAccessControl()
$rule = New-Object System.Security.AccessControl.RegistryAccessRule (".\USERS","FullControl",@("ObjectInherit","ContainerInherit"),"None","Allow")
$acl.SetAccessRule($rule)
$key.SetAccessControl($acl)
Write-Host "Successfully set permission to PM Registry!"
Access.bat
@ECHO OFF
PowerShell.exe -Command "& '%~dpn0.ps1'"
PAUSE
This is the error