Win32 Wscript.Shell puts quotes around TargetPath?

Win32 Wscript.Shell puts quotes around TargetPath?

am 30.08.2007 20:04:46 von Deane.Rothenmaier

This is a multipart message in MIME format.
--===============1045005648==
Content-Type: multipart/alternative;
boundary="=_alternative 0063502E86257347_="

This is a multipart message in MIME format.
--=_alternative 0063502E86257347_=
Content-Type: text/plain; charset="US-ASCII"

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:\foo\foo.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
--=_alternative 0063502E86257347_=
Content-Type: text/html; charset="US-ASCII"



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:\foo\foo.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

--=_alternative 0063502E86257347_=--


--===============1045005648==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1045005648==--

RE: Win32 Wscript.Shell puts quotes around TargetPath?

am 30.08.2007 20:47:33 von Jan Dubois

This is a multipart message in MIME format.

--===============1448765433==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_091A_01C7EAFB.8E68EB40"
Content-language: en-ca

This is a multipart message in MIME format.

------=_NextPart_000_091A_01C7EAFB.8E68EB40
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

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:\foo\foo.exe';

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



Cheers,

-Jan



From: activeperl-bounces@listserv.ActiveState.com [mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of
Deane.Rothenmaier@walgreens.com
Sent: August 30, 2007 11:05 AM
To: activeperl@listserv.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:\foo\foo.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


------=_NextPart_000_091A_01C7EAFB.8E68EB40
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40">


charset=3Dus-ascii">









style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:#1F497D'>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:



style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:#1F497D'> 



style=3D'font-size:11.0pt;font-family:"Courier New";
color:black'>    $oShellLink->{TargetPath} =3D =
'c:\foo\foo.exe';



style=3D'font-size:11.0pt;font-family:"Courier New";
color:black'>    $oShellLink->{Arguments}  =3D =
'23.14.15.20 1024';



style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:#1F497D'> 



style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:#1F497D'>Cheers,



style=3D'font-size:11.0pt;font-family:"Calibri","sans-serif" ;
color:#1F497D'>-Jan



style=3D'font-size:11.0pt;
font-family:"Calibri","sans-serif";color:#1F497D'>  >



0cm 4.0pt'>



0cm 0cm 0cm'>

style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"' >From:=
style=3D'font-size:10.0pt;font-family:"Tahoma","sans-serif"' >
activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of =
Deane.Rothenmaier@walgreens.com

Sent: August 30, 2007 11:05 AM

To: activeperl@listserv.ActiveState.com

Subject: Win32 Wscript.Shell puts quotes around =
TargetPath?







 





style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'> 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.




style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'> -------------=
----------
code ----------------------


use =
Win32::OLE;





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




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




style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'> $oShellLink-&=
gt;{TargetPath}
=3D 'c:\\foo\\foo.exe 23.14.15.20 1024';




style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'> $oShellLink-&=
gt;Save();





style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'> $oShellLink =
=3D
undef;


style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'> -------------=
-------------
code ---------------------------




The =
shortcut
gets created, but when I open the properties tab for it, the =
"Target"
text, c:\foo\foo.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:




style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'> $target =3D
'c:\\foo\\foo.exe 23.14.15.20 1024';


style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'> $oShellLink-&=
gt;{TargetPath}=3D
$target;




But =
that
doesn't help.




Any
suggestions?  




style=3D'font-size:10.0pt;font-family:"Arial","sans-serif"'> 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











------=_NextPart_000_091A_01C7EAFB.8E68EB40--


--===============1448765433==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1448765433==--

RE: Win32 Wscript.Shell puts quotes around TargetPath?

am 30.08.2007 20:58:22 von Deane.Rothenmaier

This is a multipart message in MIME format.
--===============1598692259==
Content-Type: multipart/alternative;
boundary="=_alternative 0068387186257347_="

This is a multipart message in MIME format.
--=_alternative 0068387186257347_=
Content-Type: text/plain; charset="US-ASCII"

Jan,

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

That did it. Thanks!

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
--=_alternative 0068387186257347_=
Content-Type: text/html; charset="US-ASCII"



Jan,



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


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




That did it.  Thanks!



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

--=_alternative 0068387186257347_=--


--===============1598692259==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1598692259==--