Jump to content

Recommended Posts

Posted (edited)

Original concept came from the application called ShortEXE found here http://www.horstmuc.de/wminis.htm#shortexe

I don't take any credit for this concept, as I saw this somewhere else. I searched here to see if it was created with Autoit, but couldn't find anything. (If found, I'll be happy to give the author credit); However, Being as I couldn't locate the original application, I decided to created a new one with some added features. Basically what this does is allows you to create a sudo shortcut in a folder that points to an application buried in sub folders. (mainly for use on removable drives, but can be used anywhere really.)

Where this program comes in handy, is when you want to create a persistent shortcut on a removable device such as external hard drive or flash drive. Windows does not let you create shortcuts that can remember paths without drive letters. If you created a standard shortcut and then moved the device to another machine, unless it has exactly the same drive letter the shortcut would fail. This application solves that issue.

Update#1: Changed the file selection mechanism to use ChooseFileFolder.au3 UDF by : Melba23 Thanks to him for the great UDF addon.

Update#2: Changed a bit of the code to handle if a program triggers the UAC (admin required)

Update#3 Fixed a bug when dealing with drive letters vs network paths when renaming the shortcut. Also changed how the shortcut is renamed to work around a limitation when using windows 10.

Update#4 Re-fixed drive letter renaming bug, that was putting a + at the start of the name.

Update#5 Added about window in first run, prevented program from selecting itself. Cosmetic bells and whistles.

Update#5a More cosmetic updates.

 

 

Edited by zone97
Expanded upon the discription of the application and uploaded code changes!

 

  Reveal hidden contents

 

  • Moderators
Posted

It's a nice concept, but if you have to locate the EXE to bind the pseudo-shortcut to anyway, what does it buy you over doing right clicking on the exe?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted (edited)
  On 12/22/2016 at 6:06 PM, JLogan3o13 said:

It's a nice concept, but if you have to locate the EXE to bind the pseudo-shortcut to anyway, what does it buy you over doing right clicking on the exe?

Expand  

You'll only have to do it once. It will rename the scripts exe to the correct format and become the shortcut. Here is an example of what I have on a thumb-drive.. Might make more sense.

explorer_2016-12-22_12-13-52.jpg

Edited by zone97
screenshot added

 

  Reveal hidden contents

 

Posted
  On 12/22/2016 at 6:06 PM, JLogan3o13 said:

It's a nice concept, but if you have to locate the EXE to bind the pseudo-shortcut to anyway, what does it buy you over doing right clicking on the exe?

Expand  

Re-read your message.. If you mean right clicking a program and making a shortcut? You can't do that on removable media. (you can, but if the drive letter changes you break the link) Shortcuts cannot be created with "relative paths" I hope that explains how this is different.

 

  Reveal hidden contents

 

  • Moderators
Posted

More or less what I was trying to get you to do. Point out to someone reading your initial post what the value was to them: i.e. the shortcut path persists.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted
  On 12/22/2016 at 7:07 PM, JLogan3o13 said:

More or less what I was trying to get you to do. Point out to someone reading your initial post what the value was to them: i.e. the shortcut path persists.

Expand  

Thanks for the guidance, original post has been updated.

 

  Reveal hidden contents

 

Posted

Might need some help. Just tested this on windows 10 and filemove nor filecopy worked? Any ideas?

 

  Reveal hidden contents

 

Posted (edited)

Im sorry, what am i missing? so i started the exe, it asks for a program, i selected one, nothing happened. It doesn't allow me to select a program in another drive, only shows the script dir contents.

Win 10 btw

Edited by careca
  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)

There seems to be an issue with windows 10 for some reason? Hopefully someone more cleaver than me can figure out what the issue is.

Update, seems to have to do with how the drive letter is assigned in windows 10.. I see an F: drive, but if I go to the command prompt and type F: it acts like it doesn't exist?

Edited by zone97

 

  Reveal hidden contents

 

Posted

Was it supposed to show other drives or what? It's supposed to be a shortcut that works even if the removable drive changes letter, right?

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)
  On 12/22/2016 at 10:23 PM, careca said:

Was it supposed to show other drives or what? It's supposed to be a shortcut that works even if the removable drive changes letter, right?

Expand  

It is designed to only see it's folder and sub-folders in that folder, it cannot see any other drives or parent folders as it's designed to work in its on folder forward, not back.

In other words.. If you had this situation.

x:\tools\tool1

x:\tools\tool2

x:\tools\tool3

and x:\tools\folder.program.exe

it will be able to see everything in x:\tools\, x:\tools\tool1, x:\tools\tool2 and x:\tools\tool3 but would not be able to navigate backwards to x:\ not designed to work that way.

Edited by zone97

 

  Reveal hidden contents

 

Posted

And therefore be able to make a shortcut into a file that's deep into a subdirectory. Regardless of the drive letter, because it's a relative shortcut. got it.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted

I've changed some things and it works in my windows 10.

;#RequireAdmin
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Icons\Folder+Program.ico
#AutoIt3Wrapper_Outfile=Program\Folder+Program.exe
#AutoIt3Wrapper_Run_Tidy=y
#Tidy_Parameters=/tc 3 /reel
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <String.au3>
#include <File.au3>
#include ".\Incudes\ChooseFileFolder.au3"
Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "", $NewFileName
If StringInStr(@ScriptName, "+") Then
   $ShortCut = StringReplace(@ScriptName, "+", "\")
   If FileExists(".\" & $ShortCut) Then
      Run(".\" & $ShortCut)
      Sleep(1000)
      _PathSplit($ShortCut, $sDrive, $sDir, $sFileName, $sExtension)
      If Not ProcessExists($sFileName & $sExtension) Then
         ShellExecute($ShortCut, "", "", "runas")
      EndIf
   Else
      $aFile = StringSplit(@ScriptName, ".")
      If StringLower($aFile[1]) <> "folder+program" Then
         MsgBox(16, "Error", "Unable to locate .\" & $ShortCut)
      EndIf
      New_File_Select()
   EndIf
Else
   New_File_Select()
EndIf
Exit
Func New_File_Select()
   $sRet = _CFF_RegMsg()
   If Not $sRet Then
      MsgBox(16, "Failure!", "Handler not registered")
      Exit
   EndIf
   $sRet = _CFF_Choose("Select a program.", 300, 300, -1, -1, @ScriptDir, "*.exe;*.com;*.bat;*.cmd")
   If $sRet Then
      $NewFileName = StringReplace($sRet, "\", "+")
      $NewFileName = _StringTitleCase($NewFileName)
      $NewFileName = StringReplace($NewFileName, ".Exe", ".exe", -1, 1)
      $NewFileName = StringTrimLeft($NewFileName, 2)
      ;If FileExists(@ScriptDir & "\" & $NewFileName) Then
      ;FileDelete(@ScriptDir & "\" & $NewFileName)
      ;EndIf
      FileMove(@AutoItExe, @ScriptDir & "\" & $NewFileName, 8)
   Else
      MsgBox(16, "Error", "No program was selected.")
   EndIf
EndFunc   ;==>New_File_Select

It was creating a file "H" without extension, so i figured it was the drive letter so i proceeded to put a string trim left for 2 characters and thats it.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted
  On 12/23/2016 at 12:14 AM, careca said:

I've changed some things and it works in my windows 10.

 

It was creating a file "H" without extension, so i figured it was the drive letter so i proceeded to put a string trim left for 2 characters and thats it.

Expand  

I think I solved the cause of this. I had to account for various types of source names such as F:\usbdrive vs f:\ vs \\network\path\to\usb etc.

@ScriptDir would report a trailing backslash when you are at the root of the drive.. IE: F: would be F:\ but if you were in a sub folder, say F:\USB would not have a trailing slash and would have to have it added.

 

  Reveal hidden contents

 

Posted (edited)

Hi mate, i just tried your app and it complained "file not found!"  and the path looks like this:

"Setup +Progs+02 Utilities+Apps+Atkpackage.exe"

"H:\Progs\02 Utilities\Apps\Atkpackage\Setup.exe"

 

EDIT Interestingly enough, or not, the code i had posted still works for me, but your final version doesn't. :\

In terms of the file choosing, i always prefer the more common file dialog, where you see the folders and it's icons and all that, but that's just an opinion.

Edited by careca
  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)

I took the liberty to change the script a bit more, for myself, only now i added filecopy so that once the executable changes name, (into a path) the original is copied so i can keep creating "new" shortcuts, instead of "losing" the exe.

;#RequireAdmin
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=FolderProgram.ico
#AutoIt3Wrapper_Res_Icon_Add=FolderProgram.ico
#AutoIt3Wrapper_Outfile=FolderProgram.exe
#AutoIt3Wrapper_Run_Tidy=y
#Tidy_Parameters=/tc 3 /reel
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <String.au3>
#include <File.au3>
FileInstall('FolderProgram.au3', @TempDir & '\FolderProgram.au3', 1)
FileInstall('FolderProgram.ico', @TempDir & '\FolderProgram.ico', 1)
FileCopy(@ScriptDir & '\FolderProgram.exe', @TempDir & '\FolderProgram.exe', 9)
TraySetIcon(@TempDir & '\FolderProgram.ico')
GUISetIcon(@TempDir & '\FolderProgram.ico')
Local $RootDir = StringSplit(@ScriptDir, '\', 1)
Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "", $NewFileName
If StringInStr(@ScriptName, "+") Then
   $ShortCut = StringReplace(@ScriptName, "+", "\")
   If FileExists($RootDir[1] & $ShortCut) Then
      Run($RootDir[1] & $ShortCut)
      Sleep(1000)
      _PathSplit($ShortCut, $sDrive, $sDir, $sFileName, $sExtension)
      If Not ProcessExists($sFileName & $sExtension) Then
         ShellExecute($ShortCut, "", "", "runas")
      EndIf
   Else
      $aFile = StringSplit(@ScriptName, ".")
      If StringLower($aFile[1]) <> "FolderProgram" Then
         MsgBox(16, "Error", "Unable to locate: " & $RootDir[1] & $ShortCut)
      EndIf
      New_File_Select()
   EndIf
Else
   New_File_Select()
EndIf
Exit
Func New_File_Select()
   $sRet = FileOpenDialog('Select a program', @ScriptDir, 'Executables (*.exe;*.com;*.bat;*.cmd)', 1)
   If @error = 0 Then
      $NewFileName = StringReplace($sRet, "\", "+")
      $NewFileName = _StringTitleCase($NewFileName)
      $NewFileName = StringReplace($NewFileName, ".Exe", ".exe", -1, 1)
      $NewFileName = StringTrimLeft($NewFileName, 2)
      FileMove(@AutoItExe, @ScriptDir & "\" & $NewFileName, 8)
      FileCopy(@TempDir & '\FolderProgram.exe', @ScriptDir & '\FolderProgram.exe', 9)
   Else
      MsgBox(16, "Error", "No program was selected.")
   EndIf
EndFunc   ;==>New_File_Select

EDIT: Now also works inside folders, replaced

".\"

by the first split of

StringSplit(@ScriptDir, '\', 1)

Edited by careca
  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted
  On 1/6/2017 at 5:24 AM, careca said:

Hi mate, i just tried your app and it complained "file not found!"  and the path looks like this:

"Setup +Progs+02 Utilities+Apps+Atkpackage.exe"

"H:\Progs\02 Utilities\Apps\Atkpackage\Setup.exe"

 

EDIT Interestingly enough, or not, the code i had posted still works for me, but your final version doesn't. :\

In terms of the file choosing, i always prefer the more common file dialog, where you see the folders and it's icons and all that, but that's just an opinion.

Expand  

Thanks for the heads up, maybe the space in the folder name is causing an issue, ill take your example and run some test and see where its failing.

 

  Reveal hidden contents

 

Posted

It works in root now, but still not inside any folder.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...