2014-04-17 131 views
1

有两个我从XP编辑的PowerShell脚本在Win Server 2k8 R2中运行。Powershell“启动过程”未按计划任务运行

它们在通过手动方式在powershell中执行时运行良好,但如果按照域管理员的计划和运行,它们将执行所有应该执行的文件操作;除非他们不会执行将文件发送到所需SFTP站点的启动进程。

他们用的参数运行powershell.exe这样展开:

-noprofile -ExecutionPolicy Bypass -file C:\Users\administrator\Documents\script1.ps1 

同样,像我前面提到的,它们运行良好,并启动start-process的要求,如果你手动运行它们,只能运行文件操作(如果它们已安排并跳过启动过程)。

start-process如下:

start-process -FilePath "c:\Program Files (x86)\Tumbleweed\STClient\stclient.exe" -ArgumentList "httpsu://www.securesiteexample.org/incoming/ $filename /prefNoAskSched /hidden /log /Remote-Site return /quitWhenDone" 

我缺少什么?

回答

0

添加一些代码来检查以确保该过程正在启动。

$FileName = 'c:\test\test.txt'; 
$ArgumentList = "httpsu://www.securesiteexample.org/incoming/ $filename /prefNoAskSched /hidden /log /Remote-Site return /quitWhenDone"; 
$ExePath = 'c:\Program Files (x86)\Tumbleweed\STClient\stclient.exe'; 

$Process = Start-Process -FilePath $ExePath -ArgumentList $ArgumentList -PassThru; 

# If $Process variable is null, then something went wrong ... 
if (!$Process) { 
    # Process did not start correctly! Write the most recent error to a file 
    Add-Content -Path $env:windir\temp\sftp.log -Value $Error[0]; 
} 
+0

感谢您的宝贵意见,将它集成并作为PowerShell运行,工作正常,上传文件。没有错误输出。按计划执行任务,移动文件周围没有上传并且没有错误输出。所以仍然令我困惑。 – user3546375

0

在你的任务,去操作窗格中,编辑和开始在场删除任何东西。

+0

“开始”字段中没有任何内容。只有程序/脚本是powershell.exe,然后是上面发布的参数。 – user3546375

相关问题