How do I run powershell scripts without admin rights?

前端 未结 5 715
再見小時候
再見小時候 2021-01-31 22:50

If I try to change the execution policy, I get a message that says I can\'t modify the registry because I\'m not an administrator.

It seems like this should be possible,

5条回答
  •  终归单人心
    2021-01-31 23:15

    if you want to have an easy way to run a script myscript.ps1 from the windows shell then all you need is a bat Runmyscript.bat with the following contents:

    type myscript.ps1 | powershell -
    

    So simple it makes me wonder why you can't just run the ps1 in the first place, but there we go.

    A generic version that prompts for userinput to type the name of the script would be:

    set /p filename="Type name of script here: "
    type %filename% | powershell -
    

    I suppose if you wanted to, you could also write a generic vbscript script that opens any file in powershell using a dialogue box using this http://todayguesswhat.blogspot.co.uk/2012/08/windows-7-replacement-for.html

提交回复
热议问题