Project

General

Profile

Actions

Bug #6843

closed

win32ole save shortcut fail on Windows XP

Added by mghomn (Justin Peal) over 12 years ago. Updated almost 12 years ago.

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

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 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

Updated by phasis68 (Heesob Park) over 12 years 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"

Updated by shyouhei (Shyouhei Urabe) over 12 years ago

  • Status changed from Open to Rejected

Not a bug.

Updated by mghomn (Justin Peal) almost 12 years ago

Thank you very much!

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0