Shortcut make strangeness

Started by seckner, October 09, 2013, 10:59:07 AM

Previous topic - Next topic

seckner

In my code I look for an icon - if it's there I delete it and then create a new one

DirChange( "\\" : Computer : "\C$\Users\Public\Desktop" )
If FileExist( "\\" : Computer : "\C$\Users\Public\Desktop\App.lnk" )
    FileDelete( "\\" : Computer : "\C$\Users\Public\Desktop\App.lnk" )
EndIf
TimeDelay( 5 )
ShortcutMake(  App.. )

If I run this in studio, works perfect every single time. Delete's and creates or just creates it. Once compiled and ran from my machine - if the icon is deleted the compiled programm will fail with the "Shortcut exists" error. Every time. Why would it work in Studio, but not as an exe?

Deana

Difficult to say. You didn't post the ShortcutMake statement that is failing. I recommend using DebugTrace. Simply add DebugTrace(@on,"trace.txt") to the beginning of the script and inside any UDF, 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.

Deana

I currently suspect a permissions issue. By default WinBatch studio runs with the manifest setting HighestAvailable/True. Make sure you are using the same manifest setting when compiling your script. Also make sure the account you are using has the necessary permissions to delete and create files in that directory.
Deana F.
Technical Support
Wilson WindowWare Inc.

seckner

Deana - thank you for your answers - sorry it took so long to respond, short but unplanned trip. Anyhow - I have to be careful here - I've included the line that are failing. If you prefer I'm happy to email everything to you but I can't use the vendors name, so..

This is being run from a domain admins Windows 7 desk (me) to a users Windows 7 unit. Being placed on the public desktop. If run from studio it works 100% of the time. If compiled and the icon's don't exist - OK. If the icons do exist we delete them and build new ones. This kills the compiled version every time - it deletes the old ones, and then will refuse to create the new ones. Again, this works using the debugger.

Just to see if I was missing something I ran this from my desktop (Windows 7 Domain Admin) to my laptop (Windows 7 Domain Admin) - same thing. Studio works - compiled fails with the below error. I searched the hard drive for that lnk file and didn't find it. Is there a difference in the way Studio looks to see if it exists?

From the trace.txt:

DirChange( "\\" : Computer : "\C$\Users\Public\Desktop" )
(16068) VALUE INT => 1

a2 = DirItemize( "*.lnk" )
(16068) VALUE UNICODE =>

If FileExist( "\\" : Computer : "\C$\Users\Public\Desktop\Program Live.lnk" )
(16084) END OPERATOR

If FileExist( "\\" : Computer : "\C$\Users\Public\Desktop\Program Test.lnk" )
(16084) END OPERATOR

TimeDelay( 5 )
(21076) VALUE INT => 1

DirChange( "\\" : Computer : "\C$\Users\Public\Desktop" )
(21076) VALUE INT => 1

ShortcutMake(  "Program Live", "\\rdsvr\program\Live\Startup\program_Start.bat", '"C:\Users\INI\program.ini"', "\\RDSvr\Program\Live\Startup", @NORMAL, 0 )
(26707) VALUE INT => 0

TERMINAL WIL ERROR=>1412 (ShortcutMake: Shortcut file already exists)

And the code:

DirChange( "\\" : Computer : "\C$\Users\Public\Desktop" )
a2 = DirItemize( "*.lnk" )
If FileExist( "\\" : Computer : "\C$\Users\Public\Desktop\Prg Live.lnk" )
   FileDelete( "\\" : Computer : "\C$\Users\Public\Desktop\Prg Live.lnk" )
EndIf
If FileExist( "\\" : Computer : "\C$\Users\Public\Desktop\Prg Test.lnk" )
   FileDelete( "\\" : Computer : "\C$\Users\Public\Desktop\Prg Test.lnk" )
EndIf
TimeDelay( 5 )
DirChange( "\\" : Computer : "\C$\Users\Public\Desktop" )
ShortcutMake(  "Prg Live", "\\rdsvr\Prg\Live\Startup\Prg_Start.bat", '"C:\Users\INI\Prg.ini"', "\\RDSvr\Prg\Live\Startup", @NORMAL, 0 )
ShortcutExtra( "Prg Live", "Prg Live", "", "C:\Users\INI\Imp.ico", 0, 0 )
ShortcutMake(  "Prg Test", "\\rdsvr\Prg\Test\Startup\Prg_Test_Start.bat", '"C:\Users\INI\Prg_test.ini"', "\\RDSvr\Prg\Test\Startup", @NORMAL, 0 )
ShortcutExtra( "Prg Test", "Prg Test", "", "C:\Users\INI\client_test.ico", 0, 0 )

Ideas?

Deana

What manifest settings are being used by your compiled script? The WinBatch+Compiler interface allows you to select the appropriate manifest for your compiled script.  The SETTINGS button in the WinBatch+Compiler can be used to specify the appropriate options. Make sure it has Highest available/True.

Deana F.
Technical Support
Wilson WindowWare Inc.

seckner

Set to Highest Available / false (I don't have code signing ability yet) UAC is off. 

Deana

Notice you shouldreference the .LNK extension in the first parameter of ShortcutMake and ShortcutExtra:

Code (winbatch) Select
ShortcutMake(  "Prg Live.lnk", "\\rdsvr\Prg\Live\Startup\Prg_Start.bat", '"C:\Users\INI\Prg.ini"', "\\RDSvr\Prg\Live\Startup", @NORMAL, 0 )
ShortcutExtra( "Prg Live.lnk", "Prg Live", "", "C:\Users\INI\Imp.ico", 0, 0 )
ShortcutMake(  "Prg Test.lnk", "\\rdsvr\Prg\Test\Startup\Prg_Test_Start.bat", '"C:\Users\INI\Prg_test.ini"', "\\RDSvr\Prg\Test\Startup", @NORMAL, 0 )
ShortcutExtra( "Prg Test.lnk", "Prg Test", "", "C:\Users\INI\client_test.ico", 0, 0 )
Deana F.
Technical Support
Wilson WindowWare Inc.