Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell脚本在复制到Powershell时运行,但在单击时不运行_Powershell - Fatal编程技术网

Powershell脚本在复制到Powershell时运行,但在单击时不运行

Powershell脚本在复制到Powershell时运行,但在单击时不运行,powershell,Powershell,我对Powershell非常陌生,只想创建一个简单的命令,我可以将其放入任务计划程序中,以便备份文件夹。我在powershell中尝试了一个简单的命令,效果很好,但当我尝试右键单击powershell中的“打开”时,它会快速打开然后关闭。我可以看到红色的错误文本,我想它会说,“字符串缺少终止符” 这是密码 Copy-Item 'C:\Users\Me\Documents' 'E:\Me\ImportantDocuments\Backup\' -recurse -force 您不能像在任务计划程

我对Powershell非常陌生,只想创建一个简单的命令,我可以将其放入任务计划程序中,以便备份文件夹。我在powershell中尝试了一个简单的命令,效果很好,但当我尝试右键单击powershell中的“打开”时,它会快速打开然后关闭。我可以看到红色的错误文本,我想它会说,“字符串缺少终止符”

这是密码

Copy-Item 'C:\Users\Me\Documents' 'E:\Me\ImportantDocuments\Backup\' -recurse -force

您不能像在任务计划程序中那样直接调用Powershell。 请执行以下操作: 对于任务计划程序“启动程序”,请指定:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
是的,我知道上面说的是v1.0,但这一点从未改变,也就是说,仍然适用于版本4

对于可选选项,请指定:
-Command&“{Copy item C:\temp\source.txt C:\temp\destination.txt}”
或者,您可以使用
-file C:\temp\test.ps1