How to start a PS script file with a batch/cmd?

deXterlab97

I have a Power Shell script file (it's PS5 on Win10) that allow me to change to a specific wallpaper when I execute it. I can only do that if I have administrator access. There are ways work around like making a .bat file

powershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file "C:\Users\name\wallp1.ps1"

But it seems that method will change execution policy permanently to unrestricted which is really unsecure What I want is to be able to execute a PS script through Task Scheduler (it must be through that not through Startup folder). I want to be able to change Wallpaper on a specific time and only Task Scheduler can do that. Unless I can do that with command or batch files.

In short: I want to run a PS script through another file without messing with current Execution Policy

Other method seems not work: how to run PowerShell Script when computer starts?

Or maybe there is a way to be able to revert back to default execution policy after the PS script has ran? It must be done automatically in one file

sodawillow

Using the launch command you provided does not change the execution policy permanently on the host. Tested on Win10 with PS5.

Second most upvoted powershell question on SO

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to start a script file on boot?

From Dev

Adding a config file to loop through for a PS script

From Dev

Convert a small PS script into a long line in a .BATch file

From Dev

How to open this file? *.ps.gz

From Dev

how to delete file that start with "-"

From Dev

How to start a script with clean environment?

From Dev

How to start a shell script within "expect script"?

From Dev

Execute PS at start up

From Dev

using a batch file to run a ps1 file but hide the command prompt after start?

From Dev

how to make command "ps" don't show password in expect script?

From Dev

How to Hide/Change name Processes called in Bash Script from ps

From Dev

How to hide a shell script running in the background from ps -ef

From Dev

How to Hide/Change name Processes called in Bash Script from ps

From Dev

How to make PS script run against each line of a csv?

From Dev

How to run a script file?

From Dev

How to run a script file

From Dev

XML file parsing: how to start

From Dev

How to start an activity that is in a jar file?

From Dev

How to execute a .ps1 from another .ps1 file?

From Dev

How to display a nested collection with .ps1xml file in powershell

From Dev

Is this a troff file, and if so how do I convert to ps or pdf?

From Dev

How to open .ps1 file in PowerShell ISE in c#

From Dev

Is this a troff file, and if so how do I convert to ps or pdf?

From Dev

how to stop a script to start xampp by default in a startup

From Dev

how to write a script that will execute xampp start and stop

From Dev

How to start a never ending script at startup

From Dev

How to start Bottle as a daemon from another script?

From Dev

How to start Splunk Forwarder within a script

From Dev

How to start Robocopy from a Powershell Script

Related Related

  1. 1

    How to start a script file on boot?

  2. 2

    Adding a config file to loop through for a PS script

  3. 3

    Convert a small PS script into a long line in a .BATch file

  4. 4

    How to open this file? *.ps.gz

  5. 5

    how to delete file that start with "-"

  6. 6

    How to start a script with clean environment?

  7. 7

    How to start a shell script within "expect script"?

  8. 8

    Execute PS at start up

  9. 9

    using a batch file to run a ps1 file but hide the command prompt after start?

  10. 10

    how to make command "ps" don't show password in expect script?

  11. 11

    How to Hide/Change name Processes called in Bash Script from ps

  12. 12

    How to hide a shell script running in the background from ps -ef

  13. 13

    How to Hide/Change name Processes called in Bash Script from ps

  14. 14

    How to make PS script run against each line of a csv?

  15. 15

    How to run a script file?

  16. 16

    How to run a script file

  17. 17

    XML file parsing: how to start

  18. 18

    How to start an activity that is in a jar file?

  19. 19

    How to execute a .ps1 from another .ps1 file?

  20. 20

    How to display a nested collection with .ps1xml file in powershell

  21. 21

    Is this a troff file, and if so how do I convert to ps or pdf?

  22. 22

    How to open .ps1 file in PowerShell ISE in c#

  23. 23

    Is this a troff file, and if so how do I convert to ps or pdf?

  24. 24

    how to stop a script to start xampp by default in a startup

  25. 25

    how to write a script that will execute xampp start and stop

  26. 26

    How to start a never ending script at startup

  27. 27

    How to start Bottle as a daemon from another script?

  28. 28

    How to start Splunk Forwarder within a script

  29. 29

    How to start Robocopy from a Powershell Script

HotTag

Archive