Advertisement
atheos42

Batch-PS

Aug 25th, 2022
67
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.66 KB | Source Code | 1 0
  1. @echo off
  2. rem https://www.howtogeek.com/204088/how-to-use-a-batch-file-to-make-powershell-scripts-easier-to-run/
  3.  
  4. rem %~dpn0 evaluates to the drive letter, folder path, and file name (without extension) of the batch file.
  5. rem PowerShell.exe -Command "& '%~dpn0.ps1'"
  6.  
  7. rem Getting around ExecutionPolicy
  8. rem PowerShell.exe -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1'"
  9.  
  10. rem Without Admin access
  11. PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%~dpn0.ps1'"
  12.  
  13. rem With Admin access
  14. rem PowerShell.exe -NoProfile -Command "& {Start-Process PowerShell.exe -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"
  15.  
  16. rem pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement