Jump to content

Recommended Posts

Posted
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()
  • Solution
Posted (edited)

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
Posted (edited)
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

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
×
×
  • Create New...