【发布时间】:2016-01-07 06:10:25
【问题描述】:
代码:
def log_it log_entry
puts log_entry
f = File.open("C:/test/test_open_file.log", "a")
f.puts log_entry
f.close
end
if File.exist?("C:/test/test_open_file.log")
File.delete("C:/test/test_open_file.log")
end
begin
f = File.open("//ServerName/sharename/sample_file.csv", "w")
puts f.class
rescue Exception => e
log_it "e.message: #{e.message}\n#{e.backtrace}"
end
当我从 cmd.exe 窗口运行它时,它运行良好,但如果我从计划任务运行它,它会失败,但有异常
e.message: Invalid argument @ rb_sysopen - //ServerName/sharename/sample_file.csv
我已经尝试过我的帐户(管理员帐户)和管理员本身,但都不能在计划任务中工作。我选择了“无论用户是否登录都运行”并选中“以最高权限运行”,并且“配置为:”设置为 Windows 7,Windows Server 2008 R2。这是一台 Windows 7 机器。我设置了“ Start in”到该脚本所在的目录。最后,我尝试在ruby.exe的属性对话框的兼容性选项卡上检查“以管理员身份运行”,没有区别。
这显然与实际尝试连接到远程服务器的帐户有关,但是如果我告诉它使用我的帐户,为什么我从命令运行它时没有问题提示?
【问题讨论】: