List Info

Thread: Win32 Wscript.Shell puts quotes around TargetPath?




Win32 Wscript.Shell puts quotes around TargetPath?
country flaguser name
Europe
2007-08-30 13:04:46

Gurus,

I'm using a new part of WMI here, so I'm sort of lost.  I'm trying to create a desktop shortcut using Wscript.Shell. The problem I've got is the TargetPath method keeps putting double-quotes around the Target text, so the shortcut can't read it.

----------------------- code ----------------------
use Win32::OLE;

my $WshShell = Win32::OLE->new( 'Wscript.Shell' );

my $oShellLink = $WshShell->CreateShortcut( 'foo.lnk' );

$oShellLink->{TargetPath} = 'c:\foo\foo.exe 23.14.15.20 1024';

$oShellLink->Save();

$oShellLink = undef;
-------------------------- code ---------------------------

The shortcut gets created, but when I open the properties tab for it, the "Target" text, c:foofoo.exe, is surrounded by double quotes. If I hand-delete the quotes and then double-click on the shortcut, foo.exe gets "found" and starts running, otherwise (with the quotes in place), a search window starts looking for it.  Is there a method in this object to suppress those quotes? Or am I missing something less obscure? Or less obvious?

I've tried assigning and using a variable for the target path:

$target = 'c:\foo\foo.exe 23.14.15.20 1024';
$oShellLink->{TargetPath}= $target;

But that doesn't help.

Any suggestions?  

TIA,

Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
847-914-5150

My goal is simple. It is complete understanding of the universe, why it is as it is and why it exists at all. -- Stephen Hawking
RE: Win32 Wscript.Shell puts quotes around TargetPath?
country flaguser name
Canada
2007-08-30 13:47:33

I think the TargetPath and Arguments are 2 separate properties. Therefore it would make sense to put quotes around the TargetPath if it looks like it contains spaces.  Try if this works:

 

    $oShellLink->{TargetPath} = 'c:foofoo.exe';

    $oShellLink->{Arguments}  = '23.14.15.20 1024';

 

Cheers,

-Jan

 

From: activeperl-bounceslistserv.ActiveState.com [mailto:activeperl-bounceslistserv.ActiveState.com] On Behalf Of Deane.Rothenmaierwalgreens.com
Sent: August 30, 2007 11:05 AM
To: activeperllistserv.ActiveState.com
Subject: Win32 Wscript.Shell puts quotes around TargetPath?

 


Gurus,

I'm using a new part of WMI here, so I'm sort of lost.  I'm trying to create a desktop shortcut using Wscript.Shell. The problem I've got is the TargetPath method keeps putting double-quotes around the Target text, so the shortcut can't read it.

----------------------- code ----------------------
use Win32::OLE;

my $WshShell = Win32::OLE->new( 'Wscript.Shell' );

my $oShellLink = $WshShell->CreateShortcut( 'foo.lnk' );

$oShellLink->{TargetPath} = 'c:\foo\foo.exe 23.14.15.20 1024';

$oShellLink->Save();

$oShellLink = undef;
-------------------------- code ---------------------------

The shortcut gets created, but when I open the properties tab for it, the "Target" text, c:foofoo.exe, is surrounded by double quotes. If I hand-delete the quotes and then double-click on the shortcut, foo.exe gets "found" and starts running, otherwise (with the quotes in place), a search window starts looking for it.  Is there a method in this object to suppress those quotes? Or am I missing something less obscure? Or less obvious?

I've tried assigning and using a variable for the target path:

$target = 'c:\foo\foo.exe 23.14.15.20 1024';
$oShellLink->{TargetPath}= $target;

But that doesn't help.

Any suggestions?  

TIA,

Deane Rothenmaier
Programmer/Analyst
Walgreens Corp.
847-914-5150

My goal is simple. It is complete understanding of the universe, why it is as it is and why it exists at all. -- Stephen Hawking

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )