Bug #6843

win32ole save shortcut fail on Windows XP

Added by Justin Peal over 1 year ago. Updated over 1 year ago.

[ruby-core:47067]
Status:Rejected
Priority:High
Assignee:-
Category:-
Target version:-
ruby -v:ruby 1.9.3p194 (2012-04-20) [i386-mingw32] Backport:

Description

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 myexe, myparams, mydir, mydesc
wsh = WIN32OLE.new('WScript.Shell')
link = wsh.CreateShortcut("#{USERPROFILE}\Desktop\#{mydesc}.lnk")
link.TargetPath = my
exe
link.Arguments = myparams
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

History

#1 Updated by Heesob Park over 1 year ago

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"

#2 Updated by Shyouhei Urabe over 1 year ago

  • Status changed from Open to Rejected

Not a bug.

#3 Updated by Justin Peal over 1 year ago

Thank you very much!

Also available in: Atom PDF