我在XP中编辑了两个powershell脚本,以便在Win Server2k8 R2中运行。
它们在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"我遗漏了什么?
发布于 2014-04-18 04:07:45
添加一些代码进行检查,以确保进程正在启动。
$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];
}发布于 2014-04-18 16:08:37
在Task中,转到Actions窗格,编辑并删除start In字段中的所有内容。
https://stackoverflow.com/questions/23140588
复制相似问题