Jump to content
meows

FileCreateShortcut works but not working right,,

Recommended Posts

meows
236

This works perfect for desktop shortcuts

$ink = "\cleaner.lnk"
$cmd = "C:\AutoIt3\Code\00_Trials\Installer\Cleaner.exe"
$icon = "C:\32.ico"                    ; & "\au3",
FileCreateShortcut($cmd , @DesktopDir & $ink  , @ScriptDir, "", "Tooltip description of the shortcut.", $icon,  @SW_MINIMIZE)

This works perfect for the Program Files Menu

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

$cmd = "C:\AutoIt3\Code\00_Trials\Installer\Cleaner.exe"
$icon = "C:\32.ico"
$ink = "\cleaner.lnk"

FileCreateShortcut($cmd , @ProgramsDir & $ink  , @ScriptDir, "", "Tooltip description of the shortcut.", $icon,  @SW_MINIMIZE)

However this has me so confused and dazed I had to change DishNet to Sirius 60's/70's Motown to chill.

My problem is I have confirmed variables for each section of the script but it does not put the variable in the correct place or it ignores it altogether,

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
Global $ifullpath
Global $iicoFile
Global $iSoftTitle
Global $iincFile
Global $incthing
;------------------$cmd = "C:\00test_Installer\00bons1.exe"
$cmd = $ifullpath
;------------------$icon = "C:\32.ico"
$icon = $iicoFile
;----------------------------$ink = "\file.ini"
$ink = $incthing
;------------------------- $iSoftTitle = \SoftTitle.ini
$Tooltip = $iSoftTitle
IniRead(@ScriptDir & "\SoftTitle.ini", "General", ".", $iSoftTitle)
 Local $iSoftTitle = IniRead(@ScriptDir & "\SoftTitle.ini", "General", ".", "")
 MsgBox(4096,"$iSoftTitle", $iSoftTitle)
; Retrieve the system environment variable called %PATH%.
    Local $sEnvVar = EnvGet("PATH")
    ; Assign the system environment variable called %PATH% with its current value as well as the script directory.
    ; When you assign an environment variable you do so minus the percentage signs (%).
    EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)
    ; Refresh the OS environment for changes to take affect.
    EnvUpdate()
IniRead(@ScriptDir & "\fullpath.ini", "General", ".", $ifullpath)
 Local $ifullpath = IniRead(@ScriptDir & "\fullpath.ini", "General", ".", "")
 MsgBox(4096,"$ifullpath", $ifullpath)
 Local $sEnvVar = EnvGet("PATH")
    ; Assign the system environment variable called %PATH% with its current value as well as the script directory.
    ; When you assign an environment variable you do so minus the percentage signs (%).
    EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)
    ; Refresh the OS environment for changes to take affect.
    EnvUpdate()
IniRead(@ScriptDir & "\icoFile.ini", "General", ".", $iicoFile)
 Local $iicoFile = IniRead(@ScriptDir & "\icoFile.ini", "General", ".", "")
  MsgBox(4096,"$iicoFile", $iicoFile)
  Local $sEnvVar = EnvGet("PATH")
    ; Assign the system environment variable called %PATH% with its current value as well as the script directory.
    ; When you assign an environment variable you do so minus the percentage signs (%).
    EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)
    ; Refresh the OS environment for changes to take affect.
    EnvUpdate()
IniRead(@ScriptDir & "\File.ini", "General", ".", $iincFile)
 Local $iincFile = IniRead(@ScriptDir & "\File.ini", "General", ".", "")
  MsgBox(4096,"$iincFile", $iincFile)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"\" & $iincFile &".ink" = $incthing
$incthing=("\" & $iincFile &".ink")
 MsgBox(4096,"$incthing", $incthing)
FileCreateShortcut($cmd , @ProgramsDir & $ink  , @ScriptDir, "", $Tooltip, $icon,  @SW_MINIMIZE)

This does make a programfiles menu item

The target is Computer and not the var $Cmd

The start in is the correct directory

It added a shortcut key! that I did not add

It ignored the comment altogether and that is empty

and the wrong icon.

01.jpg

Are there different rules if you use a variable instead of a text string?

Thanks for looking.

Oh yes I almost forgot, I use this fancy piece of code I found in the forums one day that really saved me.

I could not get things straight bouncing between things and put this in and all of a sudden the path I wanted was there,

I do apologize as I do not remember who posted it

Local $sEnvVar = EnvGet("PATH")
    ; Assign the system environment variable called %PATH% with its current value as well as the script directory.
    ; When you assign an environment variable you do so minus the percentage signs (%).
    EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)
    ; Refresh the OS environment for changes to take affect.
    EnvUpdate()

Share this post


Link to post
Share on other sites
Geir1983

I think you need to look at the order of your operations.. everything is done line by line. your $cmd for instance is always empty because you copy $ifullpath to it when $ifullpath is still not read from your ini file.

Edit: Also you have decleared $ifullpath both as a local and as a global variable, this can cause you some headace.

Edited by Geir1983

Share this post


Link to post
Share on other sites
meows
303

 

 

Oh my gosh, Thank you for the awake eyes. too many doubleshift days. THanks , it works now., just the icon not placed..

Thanks and *hugs*

 

I have no clue about anything, if it works it works until it no longer works. but thanks to some help from

I got a Filecreateshortcut using all Variables working.. YES i am positive there is another 500 versions, I just in 3 weeks of looking and trying did not find one.. so here is one Filecreateshortcut  that works using variables

#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
Global $ifullpath
Global $incthing
Global $iSoftTitle
Global $iincFile
Global $iicoFile




IniRead(@ScriptDir & "\fullpath.ini", "General", ".", $ifullpath)
 Local $ifullpath = IniRead(@ScriptDir & "\fullpath.ini", "General", ".", "")
 MsgBox(4096,"$ifullpath", $ifullpath)
 Local $sEnvVar = EnvGet("PATH")
       EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)
       EnvUpdate()
IniRead(@ScriptDir & "\File.ini", "General", ".", $iincFile)
 Local $iincFile = IniRead(@ScriptDir & "\File.ini", "General", ".", "")
  MsgBox(4096,"$iincFile", $iincFile)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"\" & $iincFile &".ink" = $incthing
$incthing=("\" & $iincFile &".ink")
 MsgBox(4096,"$incthing", $incthing)

  Local $sEnvVar = EnvGet("PATH")
    ; Assign the system environment variable called %PATH% with its current value as well as the script directory.
    ; When you assign an environment variable you do so minus the percentage signs (%).
    EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)
    ; Refresh the OS environment for changes to take affect.
    EnvUpdate()

IniRead(@ScriptDir & "\SoftTitle.ini", "General", ".", $iSoftTitle)
 Local $iSoftTitle = IniRead(@ScriptDir & "\SoftTitle.ini", "General", ".", "")
 MsgBox(4096,"$iSoftTitle", $iSoftTitle)
     Local $sEnvVar = EnvGet("PATH")
    EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)
    EnvUpdate()

IniRead(@ScriptDir & "\icoFile.ini", "General", ".", $iicoFile)
 Local $iicoFile = IniRead(@ScriptDir & "\icoFile.ini", "General", ".", "")
  MsgBox(4096,"$iicoFile", $iicoFile)

;------------------$cmd = "C:\00test_Installer\00bons1.exe"
$cmd = $ifullpath
$ink = $incthing
$Tooltip = $iSoftTitle
$icon = $iicoFile
;------------------$icon = "C:\32.ico"

;----------------------------$ink = "\file.ini"

;------------------------- $iSoftTitle = \SoftTitle.ini

FileCreateShortcut($cmd , @ProgramsDir & $ink  , @ScriptDir, "", $Tooltip, $icon,  @SW_MINIMIZE)

A note, when making the ini for icon file use FULL path

icofile.ini

[General]
.=C:AutoIt3Code00_TrialsInstaller32.ico 

Just using the file name did not work.

To test here are the files the ini and icon

http://78ez.com/Installer.7z

Thanks to Geri1983 for the second set of eyes.. and the hundreds of thousands of posts i use here at Autoit to figure things out.

*hugs* hubby is waking up. got to go and catch that midnight train

25
Edited by meows

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • sosimple
      By sosimple
      Is this possible with autoit?
      What I want to do:
      Create a Desctop windows shortcut to run an executable application created with autoit, which shortcut would have some parameters which will send as a variable to the aplicagion .
      For example:
      Create an app : ExampleAppCreatedByAutoit.exe
      Run this with a shortcut which has:  "C:/ExampleAppCreatedByAutoit.exe" -option1
      What I want to do is the ExampleAppCreatedByAutoit.exe take the option1 and do something like this: Shellexecute("c:\myfolder\option1.exe")
      Can I do that?
      Thanks,
    • Gringo
      By Gringo
      Hi,
      I'm trying to create a shortcut playing with variables but I can't figure out what's wrong
      I got 2 variables joined in one with for instance
      Local $path = FileOpenDialog($message, "C:" & "", "Select your executable (*.exe)", 1 + 4)
      Local $elev = 'c:\windows\System32\cmd.exe /c start "runhigh" /high '
      $target = $elev & $path
      FileCreateShortcut($target, @DesktopCommonDir & "\linked.lnk", StringLeft($target,StringInStr($target,"\",0,-1)) , "" , "" , "c:\i.ico")
      The problem is that a shortcut is created but instead of the target area I got the start in filled with my variable
      My second problem is that when I do a shell execute of the result of $target = $elev & $path, Note that if I do a batch with the variable written manually, it's working.
    • rudi
      By rudi
      Hello.
      Windows shortcuts have the option to check "Run as administrator" in the "advanced settings" on the tab "Shortcut"
       
      Is it possible to use the function FileCreateShortcut() to define this? Or to use this function and modify this option afterwards? Is it possible to "read" this option's current state for a given LNK file? (FileGetShortcut() doesn't seem to offer that?)  
      Regards, Rudi.
    • satanico64
      By satanico64
      hi guys, how are you ??  fine? good...
      Here is a little question: is it possible to know whish shortcut has been used to launch my autoit app ?
      i'm quite sure that there's nothing to do with autoit, but mostly windows ...
       
      My context: i have an app accessed from the network by my user.
      In my app i use FileCreateShortcut to point to \\myfileserver\myapp.exe
      Soon, in october, they are going to change my fileserver, so my app will be on \myNEWfileserver\myapp.exe
      So in my code, i just rewrite my shortcut on the desktop's user. Everything works fine.
      BUT..some users have several shortcut for my app (they just manually create another shortcut which i don't know the name).
      So maybe they don't use my shortcut but their own ...
      => i know I could list all file on desktop, and for all the .lnk i check if destination is myapp.exe and modify the path but do you see another way ?
       
      thanks
      have fun !
       
    • ur
      By ur
      I am trying to launch the shortcut through autoit, but I am getting below error.
      [Window Title] C:\Windows\system32\cmd.exe /c start "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\erwin\erwin Mart Server r9.8 (64-bit)\Create MartServer Service.lnk" [Content] Windows cannot find 'C:\Windows\system32\cmd.exe /c start "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\erwin\erwin Mart Server r9.8 (64-bit)\Create MartServer Service.lnk"'. Make sure you typed the name correctly, and then try again. [OK] Launching the target directly is not feasible as it is dynamic.
      I tried.
      $r = ShellExecute(@ComSpec & " /c " & "start """& @ProgramsCommonDir & "\erwin\erwin Mart Server r9.8 (64-bit)\Create MartServer Service.lnk""")
       
      and also Run and RUnwait
       
       
×