Issue #6843 has been updated by phasis68 (Heesob Park).


This is not a bug of ruby.
The error message OLE error code:80070003 means the target folder "#{USERPROFILE}\\Desktop" is not exist on your Windows XP.

I confirmed the folder "#{USERPROFILE}\\Desktop" is not exist on my Windows XP.
Special folders like desktop folder are mapped to another locale specific name on Windows XP.
Refer to http://www.nirsoft.net/utils/special_folders_view.html

With win32-dir gems, you can find the real path name of the desktop folder.
C:\work>irb
irb(main):001:0> require 'win32/dir'
=> true
irb(main):002:0> Dir::DESKTOPDIRECTORY
=> "F:\\Documents and Settings\\ddd\\\uBC14\uD0D5 \uD654\uBA74"

----------------------------------------
Bug #6843: win32ole save shortcut fail on Windows XP
https://bugs.ruby-lang.org/issues/6843#change-28722

Author: mghomn (Justin Peal)
Status: Open
Priority: High
Assignee: 
Category: 
Target version: 
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]


The following program will success on Windows 7, but fail on Windows XP
=======================================================================
Error message:
(in OLE method `Save': )
    OLE error code:80070003 in WshShortcut.Save
                                 C:\Documents and Settings\......
    HResult error code:0x80020009
      Exception occurred.
=======================================================================
#!/usr/bin/env ruby -w -Eutf-8:utf-8
# encoding: utf-8

require 'win32ole'

module Shortcut
  USERPROFILE = ENV['USERPROFILE']

  def self.gen my_exe, my_params, my_dir, my_desc
    wsh = WIN32OLE.new('WScript.Shell')
    link = wsh.CreateShortcut("#{USERPROFILE}\\Desktop\\#{my_desc}.lnk")
    link.TargetPath = my_exe
    link.Arguments = my_params
    link.Description = my_desc
    link.WindowStyle = 3   # WindowsStyle.showmaximized
    link.WorkingDirectory = my_dir
    link.Save
  end
end

if $0 == __FILE__
  ComSpec = ENV['ComSpec']
  Shortcut.gen(ComSpec, '/c ver', Shortcut::USERPROFILE, 'OSVER')
  system("#{ComSpec} /c #{Shortcut::USERPROFILE}\\Desktop\\OSVER.lnk")
end



-- 
http://bugs.ruby-lang.org/