Custom 'Desktop (create shortcut)' Remove .fileextension - Shortcut

Jarmezrocks

New member
Member
Local time
4:38 AM
Messages
17
Hi guys n girls,

I have for ever got sick and tired of right click -> open Send to Menu and creating a Desktop Shortcut for a file or app....then needing to go to the Desktop right click the newly made shortcut and then removing the trailing file extension, dash and words shortcut in brackets. If you are like me and you want a solution where you just right click -. Create shortcut and forget and not need to do anymore then look no further.

I have small AutoIT app (compiled script) that does exactly that.

Desktop (create shortcut).au3 SHA1 - 630A9CE23BF669035EEB089C2948BBD8B38BB505
Desktop (create shortcut).exe SHA1 - 829518AD4233E59D686822D960AAC71405D57CCD
Desktop (create shortcut).ico SHA1 - 16239287978841199F8A2FC56AA36EE55F197083

Download Link Desktop (create shortcut).zip

Virustotal readout - God knows why anyone would use any of the virus scanners flagging AutoIT as a virus. This indicates to me that they are merely only searching for header info and not actually decyphering any of the code. That should be alarming to anyone. Anyway here it is, it gets 2 false negatives out of 52.
https://www.virustotal.com/en/file/...8c0dc26f98e780ae4fc546ed/analysis/1398978188/

Now the code so that you can compile it all your self. For the Geeks in other words

Code:
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Desktop (create shortcut).ico
#AutoIt3Wrapper_Outfile=Desktop (create shortcut).exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.10.2
 Author:   Jarmezrocks
 Script Version: 1.0

 Script Function:   The purpose of creating this was due to an annoyance with Windows 7 where
					I was constantly editing the shortcuts created from the right click 'Send To'
					create 'Desktop (create shortcut)' where I would need to remove the junk that
					Microsoft attached as a postfix i.e. - (short cut) and remove the file
					extension as well. E.g. Notepad.exe -> creates a shortcut 'Notepad.exe - (shortcut)'
					when what I really wanted created was a shortcut called 'Notepad'
					This AutoIT script was created to solve this issue/annoyance.

 Usage:				Place the compiled exe where ever you like (here's the inception part LOL)
					right click the compiled exe and create a shortcut (remember you won't have to do this ever again haha)
					rename it 'Desktop (create shortcut)' the same as the Desktop (create shortcut).Desklink
					item in the Send To menu.
					Locate your Send To menu: Start -> Run -> type this: shell:sendto -> press enter
					This opens the directory for your Send To items, likely located somewhere like
					C:\Users\<User Name>\AppData\Roaming\Microsoft\Windows\SendTo
					Paste the shortcut to the exe here
					Note: You will now have a duplicate in the Send To menu, so I advise that you hide the old .Desklink item
					Right click -> File Properties -> Hidden
					Done!
					Test by Right clicking any file and choosing Send To -> Desktop (create shortcut)

 Acknowledgements:  AutoIT Forums;
					User Harlequin for this post/thread -> http://www.autoitscript.com/forum/topic/86839-how-get-file-extension/#entry623386
					User Voodooman for this post/thread -> http://www.autoitscript.com/forum/topic/122807-remove-extension-from-the-filenameexample/?p=1110846

 Future plans:		Following versions (still testing - *I have a bug I need to iron out) should allow the user to double click the executable and
					Choose to install it to the Send To context menu and automate the part outlined above in the usage section (hide the old desklink)
					and create a shortcut of it's self. It should do checking so that if the user double clicks the exe again it checks for either the
					existing Desklink extension or the shortcut.lnk and prompt the user if they want to remove it and restore the original Windows functionality.
#ce ----------------------------------------------------------------------------

Global $Input = $CmdLineRaw ; Obtain the selected file full path (name of file and location) as a string parsed as a command line parameter i.e %1
Global $LinkFileName = RemoveExt(GetFileName($Input)); Generate the file name from the input using the following functions

; These are pretty self explained - Thanks Voodooman (You may have necro-bumped an expremely old thread created by n00b years before who has now become a developer but we all forgive you - your post is valid)
Func RemoveExt($Input)
	Local $ExtArray = StringSplit($Input, ".")
	Return StringReplace($Input, "." & $ExtArray[$ExtArray[0]], "", -1)
EndFunc   ;==>RemoveExt

Func RemoveExtRegExp($Input)
	Return StringRegExpReplace($Input, "\.[^.]*$", "")
EndFunc   ;==>RemoveExtRegExp

Func GetFileName($Input)
	Local $PathArray = StringSplit($Input, "\/")
	Return $PathArray[$PathArray[0]]
EndFunc   ;==>GetFileName

;  Importance of the following. As pointed out by Harlequin using any StringRightTrim methods of obtaining the extension doesn't account for several things
;  "." can located in the path of a folder name and  "." can appear more than once within files or folders i.e What would one do when trying to return
;  the extension of a html file or any other long extension file type?

Func CreateLink()
	If $CmdLineRaw Then ;Check if it's a command parameter i.e. %1 or path to the file you want a shortcut made for
		For $YLoop = StringLen($CmdLineRaw) To 1 Step -1 ; Loop through the all of the "." in the path and string from the last "."
			If StringMid($CmdLineRaw, $YLoop, 1) == "." Then
				$Ext = StringMid($CmdLineRaw, $YLoop) ; Generate the extension type
				$YLoop = 1
			EndIf
		Next
		Local $Type = RegRead("HKEY_CLASSES_ROOT\." & $Ext, "")  ; Look up the type from the registry to find the application
		Local $FileName = $CmdLineRaw
		Local $LnkFileLocate = (@DesktopDir & "\" & $LinkFileName & ".lnk"); Here is the working part - Generate the Desktop shortcut from the derived file name
		Local $WorkingDirectory = ""
		Local $Icon = RegRead("HKEY_CLASSES_ROOT\" & $Type & "\DefaultIcon", ""); Derive the file type icon from the registered application
		Local $IconNumber = 1
		Local $Description = "" ; I decided to leav this blank
		Local $State = @SW_SHOWNORMAL ;Can also be @SW_MAXIMUM or @SW_SHOWMINNOACTIVE or even @SW_HIDE
		If Not FileExists($LinkFileName) Then ;Check there isn't already as shortcut
			FileCreateShortcut($FileName, $LnkFileLocate, $WorkingDirectory, "", $Description, $Icon, "", $IconNumber, $State); Generate the shortcut
		EndIf
	EndIf
EndFunc   ;==>CreateLink
CreateLink() ; Execute the Function
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build Asus board
OS
Windows 7 Ultimate x64
CPU
Intel Core Duo 3.4Ghz
Motherboard
Asus P5Q SE/R
Memory
Kingstone 4 x 2GB DDR2
Graphics Card(s)
Nvidia GForce E8400GT
Hard Drives
Intel 180G SSD 330 Series 2.5in SATA, Samsung 250GB 2.5in SATA, Seagate 250GB 3.5in SATA, WD 250GB 3.5in SATA, WD 1TB 3.5 SATA
Antivirus
Microsoft Security Essentials
Browser
Comodo Dragon Chrome
I must find this more annoying than most others
emoticon-dont-know.gif
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build Asus board
OS
Windows 7 Ultimate x64
CPU
Intel Core Duo 3.4Ghz
Motherboard
Asus P5Q SE/R
Memory
Kingstone 4 x 2GB DDR2
Graphics Card(s)
Nvidia GForce E8400GT
Hard Drives
Intel 180G SSD 330 Series 2.5in SATA, Samsung 250GB 2.5in SATA, Seagate 250GB 3.5in SATA, WD 250GB 3.5in SATA, WD 1TB 3.5 SATA
Antivirus
Microsoft Security Essentials
Browser
Comodo Dragon Chrome

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
That's true, it bothers me too, I'm obsessed with the control over my PC files and programs. Although, unlike you, I don't know so much about programming, I never studied programming, so I use to take more "graphic" approaches, instead, I disable the icon/file display on my desktop, I only have the picture in the background, and I use LiberKey to create shortcuts to all my apps, files and what not. That way I have a bar with all the shortcuts so I don't have to worry about the installation of software to create icons in the desktop/start menu, or have to create them myself. Thanks for the code though.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate 64bit
CPU
AMD Phenom X4 9850
Motherboard
Gigabyte Technology GA-MA74GM-S2 (Socket M2)
Memory
4.00GB Crucial Dual-Channel DDR2 @ 401MHz (5-5-5-18)
Graphics Card(s)
ATI Radeon 2100 (Gigabyte)
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
LM742 on ATI Radeon 2100
Screen Resolution
1280x1024 pixels
Hard Drives
WDC WD15EARS-00Z5B1 ATA Device, 1.5 TB, 2 partitions: - 500 GB (aprox.) Where Windows 7 resides, - 1 TB (aprox.) Storage
PSU
Ultra X4 ATX 600W
Case
ST ATX Mid-Tower Case
Cooling
Ultra Carbon X3
Keyboard
Logitech K360
Mouse
Logitech MX10
Internet Speed
802.11n USB Wireless LAN Card
Antivirus
AVG Internet Security 2014
Browser
Firefox Mozilla
Other Info
I use a graphic tablet, a XBOX360 Wired Controller, a external CD/DVD Driver, and my entire system is connected to a 6 slots Protected Power-surge
If you like, here's an easier way to remove the "shortcut" name extension when you create a new shortcut. :)

How to Remove or Restore the "Shortcut" Name Extension in Windows 7 and Windows 8

Brink,

Thanks for bringing that to my attentions. Someone on the AutoIT forums did also. However I made them aware of one difference and it is still just as annoying as 'almost solution' for shortcuts you posted.

Dammit!

Hmm hang on? Wait that will only remove - Shortcut right?

What about the file extension?

notpad.exe normally goes to -> notepad.exe - Shortcut

Registry edit
notepad.exe goes to -> notepad.exe

I still then need to double long click or right click shortcut properties and remove .exe from the end.

What I want then is this
notepad.exe goes to -> notepad

Or maybe I could improve it to reproduce the link in propercase Or propercase with string replace to substitute dashes and underscores

notepad.exe goes to -> Notepad

and

this-is-the-name-of-a-long-executable_1.exe goes to -> This is the name of a long executable 1
My snippet still applies I guess? But thanks for the reg hack. I have no idea why I never come across that earlier?

I guess for me, it all comes back to a work process efficiency thing for me. I mean if you have to edit it for one thing then you may as well leave it and forever edit it for all the things right? I was wanting to create shortcut that I was happy to leave in place without changing anything what so ever. This I think mostly does that, and more importantly I shared the code so that other people interested can use parts of it in ideas that they might have. It's not really about the desklink it's self.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build Asus board
OS
Windows 7 Ultimate x64
CPU
Intel Core Duo 3.4Ghz
Motherboard
Asus P5Q SE/R
Memory
Kingstone 4 x 2GB DDR2
Graphics Card(s)
Nvidia GForce E8400GT
Hard Drives
Intel 180G SSD 330 Series 2.5in SATA, Samsung 250GB 2.5in SATA, Seagate 250GB 3.5in SATA, WD 250GB 3.5in SATA, WD 1TB 3.5 SATA
Antivirus
Microsoft Security Essentials
Browser
Comodo Dragon Chrome

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
You could also use this below to hide/show known file extensions.

http://www.sevenforums.com/tutorials/10570-file-extensions-hide-show.html

Your good man :D you are definitely on to it ;)

However.....
This is where my OCD gets you on that one. I can't have extensions for known filetypes check and hidden. As say a more 'Advanced' user of Windows and explorer I definitely cannot operate happily with this functionality absent. Personally I feel vulnerable not being able to distinguish file types. How anyone else can also is beyond me?

Question....just out of interest, Do you have hide extensions for known files types enabled on your own personal Windows?

PS: I've been a quiet lurker of these forums and others on the web and brink I still gobsmacked at just how much you know about the Windows registry! Take this as a complement brink =
9Lg8vG
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build Asus board
OS
Windows 7 Ultimate x64
CPU
Intel Core Duo 3.4Ghz
Motherboard
Asus P5Q SE/R
Memory
Kingstone 4 x 2GB DDR2
Graphics Card(s)
Nvidia GForce E8400GT
Hard Drives
Intel 180G SSD 330 Series 2.5in SATA, Samsung 250GB 2.5in SATA, Seagate 250GB 3.5in SATA, WD 250GB 3.5in SATA, WD 1TB 3.5 SATA
Antivirus
Microsoft Security Essentials
Browser
Comodo Dragon Chrome
Oh no. I have to have all my file extensions showing. :)
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Self built custom
OS
64-bit Windows 11 Pro for Workstations
CPU
Intel i7-8700K OC'd to 5 GHz
Motherboard
ASUS ROG Maximus XI Formula Z390
Memory
64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz
Graphics Card(s)
ASUS ROG-STRIX-GTX1080TI-O11G-GAMING
Sound Card
Integrated
Monitor(s) Displays
2 x Samsung Odyssey G7 27"
Screen Resolution
2560x1440
Hard Drives
1TB Samsung 990 PRO M.2,
4TB Samsung 990 PRO PRO M.2,
TerraMaster F8 SSD Plus NAS
PSU
Seasonic Prime Titanium 850W
Case
Thermaltake Core P3
Cooling
Corsair Hydro H115i
Keyboard
Logitech wireless K800
Mouse
Logitech MX Master 4
Internet Speed
2 Gb/s Download and 100 Mb/s Upload
Antivirus
Malwarebyte Anti-Malware Premium
Browser
Google Chrome
Other Info
Logitech Z625 speaker system,
Logitech BRIO 4K Pro webcam,
HP Color LaserJet Pro MFP M477fdn,
APC SMART-UPS RT 1000 XL - SURT1000XLI,
Galaxy S23 Plus phone
Oh no. I have to have all my file extensions showing. :)

Yeah, me too, it makes my work easier when I have to encrypt several files, and I'm very particular, because first I compress the file, then I encrypt it using DCU, then I delete the extensions, just for a second barrier, but that's another story.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate 64bit
CPU
AMD Phenom X4 9850
Motherboard
Gigabyte Technology GA-MA74GM-S2 (Socket M2)
Memory
4.00GB Crucial Dual-Channel DDR2 @ 401MHz (5-5-5-18)
Graphics Card(s)
ATI Radeon 2100 (Gigabyte)
Sound Card
Realtek High Definition Audio
Monitor(s) Displays
LM742 on ATI Radeon 2100
Screen Resolution
1280x1024 pixels
Hard Drives
WDC WD15EARS-00Z5B1 ATA Device, 1.5 TB, 2 partitions: - 500 GB (aprox.) Where Windows 7 resides, - 1 TB (aprox.) Storage
PSU
Ultra X4 ATX 600W
Case
ST ATX Mid-Tower Case
Cooling
Ultra Carbon X3
Keyboard
Logitech K360
Mouse
Logitech MX10
Internet Speed
802.11n USB Wireless LAN Card
Antivirus
AVG Internet Security 2014
Browser
Firefox Mozilla
Other Info
I use a graphic tablet, a XBOX360 Wired Controller, a external CD/DVD Driver, and my entire system is connected to a 6 slots Protected Power-surge
I guess I show up late:)
Anyway, thank you so much I've been looking for a solution like this for years, being tired of removing the .exe extensions every time I copy a shortcut to the desktop.
Although the link is dead, I could copy the script and compile it with AutoIt and simply follow the instructions in the script.
Thank you so much for this solution.
/arc

P.S. I still works for Win 10.
 

My Computer My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Msft Surface Pro
OS
Windows 7 Ultimate x64
CPU
Intel i7 2.2GHz
Memory
16GB
Hard Drives
1 TB
Antivirus
ESET Internet Security
Browser
Chro
Back
Top