Trying to create a shortcut

Started by jkjk12, May 07, 2014, 11:11:17 AM

Previous topic - Next topic

jkjk12

I've looked at the help for makeshortcut but my syntax is wrong.   sorry for such an easy question but I'm new to this tool.

I need to create a shortcut that has the following properties.

link-name:   PSupply
target file:   c:\program files\PSupply\P_Supply.exe
start dir:      c:\program files\PSupply
icon file:       c:\program files\PSupply\P_Supply.exe

what is the proper code for that?


Deana

Use ShortcutMake:

Code (winbatch) Select

shortcutname = DirScript():'PSupply.lnk'
target = 'c:\program files\PSupply\P_Supply.exe'
startdir = 'c:\program files\PSupply\'
ShortcutMake( shortcutname, target, '', startdir, @normal, 0 )
exit
Deana F.
Technical Support
Wilson WindowWare Inc.

Deana

Instead of using DirScript() use:

Code (winbatch) Select
shortcutname = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Department Applications\PSupply.lnk'
Deana F.
Technical Support
Wilson WindowWare Inc.

jkjk12

I had to modify the shortcutname so it would get installed in the location that we need.  When I run this it works on Windows 7 but not Windows XP.  and I have to make it work on Windows XP.     The error I get is this:

Error:  U:\psupply.exe
1420:  shortcut function:  error saving shortcut file
on line 4 of U:\psupply.wbt
ShortcutMake( shortcutname, target, '', startdir, @normal, 0 )

so how do I make this work on Windows XP?   and yes, I am running this with Admin rights on XP.


jkjk12

I even added the wwwnt34i.dll to my compiled .EXE and it still fails on XP

Deana

Quote from: jkjk12 on May 07, 2014, 12:56:32 PM
I had to modify the shortcutname so it would get installed in the location that we need.  When I run this it works on Windows 7 but not Windows XP.  and I have to make it work on Windows XP.     The error I get is this:

Error:  U:\psupply.exe
1420:  shortcut function:  error saving shortcut file
on line 4 of U:\psupply.wbt
ShortcutMake( shortcutname, target, '', startdir, @normal, 0 )

so how do I make this work on Windows XP?   and yes, I am running this with Admin rights on XP.

Is U:\ a mapped drive? You might need to add code to check if the drive is mapped.

If you need further assistance. I recommend using DebugTrace. Simply add DebugTrace(@on,"trace.txt") to the beginning of the script, run it until the error or completion, then inspect the resulting trace file for clues as to the problem

Feel free to post the trace file here ( removing any private info) if you need further assistance.
Deana F.
Technical Support
Wilson WindowWare Inc.

jkjk12

Yes U: is mapped but even when I copy the .EXE to my local XP workstation it still fails with the same error.      Here is my exact code:  It looks a little different since I need to create 2 icons and this is the one I've worked on the most.


DebugTrace(@on,"c:\temp\trace.txt")
shortcutname = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Department Applications\Paragon.lnk"
target = 'C:\Program Files\Paragon120975\patient_supply.exe'
startdir = 'C:\Program Files\Paragon120975\'
ShortcutMake( shortcutname, target, '', startdir, @normal, 0 )
exit


trace.txt says this:



************************************************************

*** Debug Initialized ***

==============================
Wed 5/7/2014 1:30:00 PM
WinBatch 32 2014A
WIL DLL 6.14ana
C:\temp\PI.exe
Windows platform: NT, version: 5.1, build: 2600 (Service Pack 3)
ErrorMode: @CANCEL
Valid Code Signature: No
UAC Manifest Settings: level="asInvoker" uiAccess="false"
UAC Elevation Level: Unsupported Platform
==============================

shortcutname = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Department Applications\Paragon.lnk"
(0) VALUE STRING => "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Department Applications\Paragon.lnk"

target = 'C:\Program Files\Paragon120975\patient_supply.exe'
(0) VALUE STRING => "C:\Program Files\Paragon120975\patient_supply.exe"

startdir = 'C:\Program Files\Paragon120975\'
(0) VALUE STRING => "C:\Program Files\Paragon120975\"

ShortcutMake( shortcutname, target, '', startdir, @normal, 0 )
(1219) VALUE INT => 0

TERMINAL WIL ERROR=>1420 (Shortcut functions: Error saving shortcut file)

;;;END OF JOB;;;

---------- Begin structure stack dump ----------

-------- End structure stack dump --------

---------- Begin WWWBATCH.INI dump ----------
<File not found>
----------- End WWWBATCH.INI dump -----------




Deana

C:\ProgramData doesn't exist on XP.

Have you considered using ShortCutDir to dynamically grab the start menu directory path on any platform:

Code (winbatch) Select
startmenudir = ShortCutDir( "Common Start Menu", 0, 0 )
shortcutname = startmenudir:'\Programs\Department Applications\PSupply.lnk'
target = 'c:\program files\PSupply\P_Supply.exe'
startdir = 'c:\program files\PSupply\'
ShortcutMake( shortcutname, target, '', startdir, @normal, 0 )
exit
Deana F.
Technical Support
Wilson WindowWare Inc.

jkjk12

OK, I ran this locally on my XP workstation.  it failed with the same error.   trace.txt says:


************************************************************

*** Debug Initialized ***

==============================
Wed 5/7/2014 2:44:42 PM
WinBatch 32 2014A
WIL DLL 6.14ana
C:\temp\PI.exe
Windows platform: NT, version: 5.1, build: 2600 (Service Pack 3)
ErrorMode: @CANCEL
Valid Code Signature: No
UAC Manifest Settings: level="asInvoker" uiAccess="false"
UAC Elevation Level: Unsupported Platform
==============================

startmenudir = ShortCutDir( "Common Start Menu", 0, 0 )
(0) VALUE STRING => "C:\Documents and Settings\All Users\Start Menu"

shortcutname = startmenudir:'\Programs\Department Applications\Paragon.lnk'
(0) VALUE STRING => "C:\Documents and Settings\All Users\Start Menu\Programs\Department Applications\Paragon.lnk"

target = 'C:\Program Files\Paragon120975\patient_supply.exe'
(0) VALUE STRING => "C:\Program Files\Paragon120975\patient_supply.exe"

startdir = 'C:\Program Files\Paragon120975\'
(0) VALUE STRING => "C:\Program Files\Paragon120975\"

ShortcutMake( shortcutname, target, '', startdir, @normal, 0 )
(6594) VALUE INT => 0

TERMINAL WIL ERROR=>1420 (Shortcut functions: Error saving shortcut file)

;;;END OF JOB;;;

---------- Begin structure stack dump ----------

-------- End structure stack dump --------

---------- Begin WWWBATCH.INI dump ----------
<File not found>
----------- End WWWBATCH.INI dump -----------

jkjk12

any help on this?   Does winbatch 2014 work on XP is a question I have.    is it does how come this code does not work?  thanks 

Deana

Quote from: jkjk12 on May 08, 2014, 06:15:19 AM
any help on this?   Does winbatch 2014 work on XP is a question I have.    is it does how come this code does not work?  thanks

Yes WinBatch 2014 is compatible with Windows XP.

I suspect the target directory for your shortcut does not already exist. Can you confirm that this folder already exists?

C:\Documents and Settings\All Users\Start Menu\Programs\Department Applications\

If it doesn't you will need to add DirMake command to create the directory before calling ShortcutMake.
Deana F.
Technical Support
Wilson WindowWare Inc.

jkjk12

Hi.  Yes, I am 100% sure the path exists.  It is baked into the XP image and all machines have it.  It is where we play 15 or so shortcuts for company wide apps.

Deana

Quote from: jkjk12 on May 08, 2014, 11:38:24 AM
Hi.  Yes, I am 100% sure the path exists.  It is baked into the XP image and all machines have it.  It is where we play 15 or so shortcuts for company wide apps.

Okay, please run this code on the Xp system and post the resulting trace.txt file output:

Code (winbatch) Select
DebugTrace( @On , DirScript():'trace.txt' )
startmenudir = ShortCutDir( "Common Start Menu", 0, 0 ); "C:\Documents and Settings\All Users\Start Menu"
shortcutname = startmenudir:'\Programs\Department Applications\Paragon.lnk'; "C:\Documents and Settings\All Users\Start Menu\Programs\Department Applications\Paragon.lnk"
target = 'C:\Program Files\Paragon120975\patient_supply.exe'
startdir = 'C:\Program Files\Paragon120975\'

If DirExist( startmenudir )
  Pause('Notice','Directory does not exist':@lf:startmenudir)
Endif

shortcutdirectory = startmenudir:'\Programs\Department Applications\'
If DirExist( shortcutdirectory )
  Pause('Notice','Shorcut Directory does not exist':@lf:shortcutdirectory)
Endif
Deana F.
Technical Support
Wilson WindowWare Inc.

jkjk12

ok, more data

C:\Documents and Settings\All Users\Start Menu\Department Applications   ; this is the actual location on all of our XP systems where the shortcuts go.
"C:\Documents and Settings\All Users\Start Menu\Programs\Department Applications"  ;  this is where the WinBatch code is looking for.




************************************************************

*** Debug Initialized ***

==============================
Thu 5/8/2014 2:49:48 PM
WinBatch 32 2014A
WIL DLL 6.14ana
C:\temp\PI2.exe
Windows platform: NT, version: 5.1, build: 2600 (Service Pack 3)
ErrorMode: @CANCEL
Valid Code Signature: No
UAC Manifest Settings: level="asInvoker" uiAccess="false"
UAC Elevation Level: Unsupported Platform
==============================

startmenudir = ShortCutDir( "Common Start Menu", 0, 0 ); "C:\Documents and Settings\All Users\Start Menu"
(0) VALUE STRING => "C:\Documents and Settings\All Users\Start Menu"

shortcutname = startmenudir:'\Programs\Department Applications\Paragon.lnk'; "C:\Documents and Settings\All Users\Start Menu\Programs\Department Applications\Paragon.lnk"
(0) VALUE STRING => "C:\Documents and Settings\All Users\Start Menu\Programs\Department Applications\Paragon.lnk"

target = 'C:\Program Files\Paragon120975\patient_supply.exe'
(0) VALUE STRING => "C:\Program Files\Paragon120975\patient_supply.exe"

startdir = 'C:\Program Files\Paragon120975\'
(0) VALUE STRING => "C:\Program Files\Paragon120975\"

If DirExist( startmenudir )
(0) IF DO==>TRUE

Pause('Notice','Directory does not exist':@lf:startmenudir)
(4078) VALUE INT => 1

Endif
(4078) END OPERATOR

shortcutdirectory = startmenudir:'\Programs\Department Applications\'
(4078) VALUE STRING => "C:\Documents and Settings\All Users\Start Menu\Programs\Department Applications\"

If DirExist( shortcutdirectory )
(4078) END OPERATOR

--- Normal termination ---

;;;END OF JOB;;;

Deana

As expected the path in your script DID NOT exist, hence the error.

You can easily specify the correct directory path by removing ''\Programs" from your shortcutname variable definition:

Code (winbatch) Select
shortcutname = startmenudir:'\Department Applications\Paragon.lnk'

Deana F.
Technical Support
Wilson WindowWare Inc.