shortcut on desktop

224 views
Skip to first unread message

timepro timesheet

unread,
Oct 20, 2020, 5:00:00 AM10/20/20
to
hi all:

my app is in xhb+wvw+ps32+dbf

how to auto-create a shortcut in win10 from within my app.

from within my app, users can output reports to .xlsx format.
that .xlsx output is saved to: 'driveletter:\tax\xlsxfiles\thexlsfilename'

now, when the user wants to re-access that file, he/she has to:
on the desktop
click on thispc
click on the drive (where my app is located)
click on 'tax folder'
click on 'xlsxfiles folder'
click on that .xlsx file

is there a way to (from within my app), a shortcut can be created on the desktop, with the target 'driveletter:\tax\xlsxfiles'

(the client system could have win10 installed in c: or d: or e:)

thanks

Rick Lipkin

unread,
Oct 21, 2020, 12:30:51 PM10/21/20
to

Rick Lipkin

unread,
Oct 21, 2020, 12:34:24 PM10/21/20
to
If it were me .. I would create a master short-cut from one of your machines .. then create a Login script that copies that short-cut to everyone's desktop and when they login to the network .. the script should fire and copy your file to everyone's computer.

Rick Lipkin

Ninoslav Micic

unread,
Oct 22, 2020, 4:53:49 AM10/22/20
to
On Wednesday, October 21, 2020 at 6:34:24 PM UTC+2, Rick Lipkin wrote:
> If it were me .. I would create a master short-cut from one of your machines .. then create a Login script that copies that short-cut to everyone's desktop and when they login to the network .. the script should fire and copy your file to everyone's computer.
>
> Rick Lipkin
That is ok, but question was "how to auto-create a shortcut in win10 from within my app."
Does anybody know.
That will be very helpfull.

Enrico Maria Giordano

unread,
Oct 22, 2020, 5:16:28 AM10/22/20
to


Il 22/10/2020 10:53, Ninoslav Micic ha scritto:

> That is ok, but question was "how to auto-create a shortcut in win10 from within my app."
> Does anybody know.
> That will be very helpfull.

FUNCTION CREATELINK( cLnk, cPath )

LOCAL oShell, oLink

LOCAL lOk := .F.

BEGIN SEQUENCE
oShell = CREATEOBJECT( "WScript.Shell" )

oLink = oShell:CreateShortCut( cLnk )

oLink:TargetPath = cPath

oLink:Save()

lOk = .T.
END SEQUENCE

RETURN lOk

EMG

http://www.emagsoftware.it
http://www.emagsoftware.it/emgmusic
http://www.emagsoftware.it/spectrum
http://www.emagsoftware.it/tbosg

Ninoslav Micic

unread,
Oct 24, 2020, 3:17:13 PM10/24/20
to
Many thanks Enrico.
That is very helpful fo me.
Regards

timepro timesheet

unread,
Oct 28, 2020, 1:40:13 AM10/28/20
to

*at RUN TIME i get this: (my app is in: xhb+wvw+dbf+ps32)

############################## Video Screen Dump ##############################

+--------------------------------------------------------------------------------+
| |
|Error WScript.Shell/3 DISP_E_MEMBERNOTFOUND: CREATESHORTCUT Arguments: ( [ 1] =|
| Type: C Val: E:\taxaccounts\taxgst.exe) |
| |
|Error at ...: TOLEAUTO:CREATESHORTCUT(0) in Module: |
|Called from : MAIN(385) in Module: mytax.PRG |
+--------------------------------------------------------------------------------+

what have i done wrong. (have never used: 'begin sequence...end sequence' until now)

:my coding

**********
proce main
**********
request HB_GT_WVW_DEFAULT
public p_nNormalMaxrow:=33,p_nNormalMaxcol:=98
public _aObj := {}
wvw_size_ready(.t.)
fullskreen=.f.;nfskr=800;fskr=500;ap64dll='64bitprn.dll';wsettitle='';lockfile='';ml_image='';ogir='C';calogoprn='Y';dept1name='dept 1';dept2name='dept 2';p2heading='partner-2';p3heading='partner-3';duedays=30
setcolor('n/w,n/gr*,,,n/w')
cls
nWin:=0 // or the return of wvw_nOpenWindow(...)
nwindow:=nwin
wvw_setcodepage(,255)
wvw_setpaintrefresh(150)
ScreenWidth:=Wvw_GetScreenWidth()
ScreenHeight:=Wvw_GetScreenHeight()
nowheight=Wvw_GetScreenHeight()
nowwidth=Wvw_GetScreenWidth()
SetMode(25,80)
nNewHeight=int(ScreenHeight/maxrow() * 0.85);NewHeightori=nNewHeight
nNewWidth=Int( ScreenWidth/maxcol()-.5);NewWidthori=nNewWidth
wvw_SetFont(, 'Courier New', nNewHeight, nNewWidth,900)

CREATELNK()
...
...

if choice=1
dothis()
elseif choice=2
dothat()
elseif choice=3
doother()
...
end



*eo(main)

**************
func createlnk
**************

BEGIN SEQUENCE
oShell = CREATEOBJECT( "WScript.Shell" )

oLink = oShell:CreateShortCut( diskname()+':\taxaccounts\taxgst.exe')

oLink:TargetPath = (diskname()+':\taxaccounts')

oLink:Save()

END SEQUENCE


Enrico Maria Giordano

unread,
Oct 28, 2020, 5:28:39 AM10/28/20
to
oLink = oShell:CreateShortCut( diskname()+':\taxaccounts.lnk')

oLink:TargetPath = (diskname()+':\taxaccounts\taxgst.exe')

timepro timesheet

unread,
Oct 28, 2020, 7:44:34 AM10/28/20
to
thanks emg:

bur to create a shortcut (on the desktop) for a folder (from inside my app),
if i code: oLink = oShell:CreateShortCut(diskname()+':\xlsfiles.lnk')
it will create a shortcut in the root of diskname(), thereby not visible/clickable from the desktop.
-how to get the shortcut directly on the desktop. (win10-64)

typically (not always) in the created shortcut 'properties-details-folder path' - it should show: (if win10 installed in c:)
c:\users\xxxxx\desktop (here xxxx would be that computer name)
or
c:\users\desktop
or
c:\admin\xxxxx\desktop
or
...

or, have i still got it wrong?


Enrico Maria Giordano

unread,
Oct 28, 2020, 10:24:37 AM10/28/20
to


Il 28/10/2020 12:44, timepro timesheet ha scritto:

> -how to get the shortcut directly on the desktop. (win10-64)

FUNCTION MAIN()

? GETDESKTOPDIR()

INKEY( 0 )

RETURN NIL


#define HKEY_CURRENT_USER 2147483649
#define HKEY_LOCAL_MACHINE 2147483650

#define KEY_ALL_ACCESS 983103

#define REG_SZ 1


STATIC FUNCTION GETDESKTOPDIR()

LOCAL hKey := 0

LOCAL nType := 0

LOCAL cData := SPACE( 256 )

LOCAL nSize := LEN( cData )

REGOPENKEY( HKEY_CURRENT_USER,
"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders",
KEY_ALL_ACCESS, @hKey )

REGQUERYVALUE( hKey, "Desktop", @nType, @cData, @nSize )

REGCLOSEKEY( hKey )

RETURN LEFT( cData, AT( CHR( 0 ), cData ) - 1 )


#pragma BEGINDUMP

#include "windows.h"

HB_FUNC( REGOPENKEY )
{
HKEY hKey = ( HKEY ) hb_parnl( 1 );

hb_retnl( RegOpenKeyEx( hKey, hb_parc( 2 ), 0, ( REGSAM ) hb_parnl(
3 ), &hKey ) );

hb_stornl( ( LONG ) hKey, 4 );
}


HB_FUNC( REGQUERYVALUE )
{
DWORD nType = ( DWORD ) hb_parnl( 3 );
DWORD nSize = ( DWORD ) hb_parnl( 5 );

hb_retnl( RegQueryValueEx( ( HKEY ) hb_parnl( 1 ), hb_parc( 2 ), 0,
&nType, ( LPBYTE ) hb_parc( 4 ), &nSize ) );

hb_stornl( ( LONG ) nType, 3 );
hb_stornl( ( LONG ) nSize, 5 );
}


HB_FUNC( REGCLOSEKEY )
{
hb_retnl( RegCloseKey( ( HKEY ) hb_parnl( 1 ) ) );
}

#pragma ENDDUMP

Ninoslav Micic

unread,
Oct 29, 2020, 9:01:52 AM10/29/20
to
This code works fine for me:

Func CREATELINK( cLnk, cPath , cIconNaz, cArg, cIconLoc)
LOCAL oShell, oLink
LOCAL lOk := .F.
DEFAULT cPath TO "C:\PHOENIX\NIMI.EXE"
DEFAULT cArg TO ""
DEFAULT cIconLoc TO DSlovo + ":\prenos\install\PHOENIX.ico"
DEFAULT cIconNaz TO "Ikona"
DEFAULT cLnk TO ALLTRIM(GetEnv("USERPROFILE"))+"\Desktop\"+cIconNaz+".lnk"
BEGIN SEQUENCE
oShell := CREATEOBJECT( "WScript.Shell" )
oLink = oShell:CreateShortCut( cLnk )
oLink:TargetPath = (cPath)
oLink:Arguments = cArg
oLink:IconLocation = cIconLoc

timepro timesheet

unread,
Apr 26, 2022, 6:37:40 AMApr 26
to
thanks emg, thanks ninoslav:

this works,
CREATELINK(ALLTRIM(GetEnv('USERPROFILE'))+'\Desktop\JSON_OUT.LNK', diskname()+':\tax\gst\taxinvoice.exe')
it auto created an icon on the desktop, from within my app.
in 'Target' it shows E:\TAX\GST\TAXINVOICE.EXE

but the 'Start In' remains blank. (in the auto created JSON_OUT.LNK)
how to ALSO auto-fill the 'Start In' (with the drive,folder of the .exe file. i.e.: diskname()+':\TAX\GST')

i tried
oLink:Start=diskname()+':\TAX\GST'
oLink:StartIn=diskname()+':\TAX\GST'
oLink:StartInPath=diskname()+':\TAX\GST'

but none works. it crashes.

FUNCTION CREATELINK(C1,C2)
*********************************
BEGIN SEQUENCE
oShell=CREATEOBJECT("WScript.Shell")
oLink=oShell:CreateShortCut(C1)
oLink:TargetPath=C2
oLink:Save()
END SEQUENCE



timepro timesheet

unread,
Apr 26, 2022, 8:04:35 AMApr 26
to
googled and got it... ('Start In')
olink:WorkingDirectory=
Reply all
Reply to author
Forward
0 new messages