--- In [email protected], "chunwaihome" <[EMAIL PROTECTED]> wrote:
>
> --- In [email protected], "Sheri" <sherip99@> wrote:
> >
> > --- In [email protected], "chunwaihome" <chunwaihome@>
> wrote:
> > >
> > > hello;
> > > local var = file.name ("&(clip.get)")
> > >
> > > file.createShortcut(?"&(clip.get)", ?"C:\Documents and
> > > Settings\Administrator\desktop\&(var)")
> > >
> > > this script will get filename from clipboard and make a shortcut
> > > to the desktop. But it has not work, it will work if i change
> > > "&(var)" to other word e.g. abc
> >
> > You're trying to use the evaluator &() inside literal strings.
> >
> > This should work:
> >
> > local var=file.name(clip.get)
> > file.createShortcut(clip.get, ?"C:\Documents and
> > Settings\Administrator\desktop\"++var)
> >
> It dont work
> thx
Works for me, but it doesn't care if the file name is bad so it would
be safer if you first test that the clipboard references a valid file.
I don't have Administrator\Desktop so I used All Users\Desktop.
It would probably also be safer to assign clip.get to a variable and
use it in the functions instead of clip.get. Its unlikely, but another
app could potentially change the clipboard.
if (not file.validpath(clip.get)) do
messagebox("OK", "File doesn't exist", "Create Shortcut Failed")
quit
endif
local dest=?"C:\Documents and Settings\All Users\Desktop\"
local var=file.name(clip.get)
local x=file.createShortcut(clip.get, dest++var)
messagebox("OK",Ifelse(x==1,"Success","Failure"), ;;+
"Create shortcut "++dest++var++".lnk")
If you want this in a pcf command list item, you could use *Exec
MoreCommandsasScript as the command and paste the above script into
the area for more commands.
Regards,
Sheri