Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

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

01 May 2014   #1

Windows 7 Ultimate x64
Custom 'Desktop (create shortcut)' Remove .fileextension - Shortcut

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.

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

#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:
 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
					Test by Right clicking any file and choosing Send To -> Desktop (create shortcut)

 Acknowledgements:  AutoIT Forums;
					User Harlequin for this post/thread ->
					User Voodooman for this post/thread ->

 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
		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
EndFunc   ;==>CreateLink
CreateLink() ; Execute the Function

My System SpecsSystem Spec
05 May 2014   #2

Windows 7 Ultimate x64

I must find this more annoying than most others
My System SpecsSystem Spec
05 May 2014   #3

64-bit Windows 10 Pro

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
My System SpecsSystem Spec

05 May 2014   #4
Damian Adelle

Windows 7 Ultimate 64bit

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 System SpecsSystem Spec
08 May 2014   #5

Windows 7 Ultimate x64

Quote   Quote: Originally Posted by Brink View Post
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

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.


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


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 System SpecsSystem Spec
08 May 2014   #6

64-bit Windows 10 Pro

You could also use this below to hide/show known file extensions.

File Extensions - Hide or Show
My System SpecsSystem Spec
11 May 2014   #7

Windows 7 Ultimate x64

Quote   Quote: Originally Posted by Brink View Post
You could also use this below to hide/show known file extensions.

File Extensions - Hide or Show
Your good man you are definitely on to it

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 =
My System SpecsSystem Spec
11 May 2014   #8

64-bit Windows 10 Pro

Oh no. I have to have all my file extensions showing. :)
My System SpecsSystem Spec
14 May 2014   #9
Damian Adelle

Windows 7 Ultimate 64bit

Quote   Quote: Originally Posted by Brink View Post
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 System SpecsSystem Spec
19 Dec 2019   #10

Windows 7 Ultimate x64

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.

P.S. I still works for Win 10.
My System SpecsSystem Spec

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

Thread Tools

Similar help and support threads
Thread Forum
Show Desktop Shortcut - Create
How to Create a "Show Desktop" Shortcut in Windows 7 and Windows 8 Show Desktop was a feature present in Windows XP and Windows Vista, but has been changed to the Aero Peek/Show Desktop button on the bottom right corner of the screen, near the Notification Area in Windows 7 and Windows 8. ...
Safely Remove Hardware Shortcut - Create
How to Create a "Safely Remove Hardware" Shortcut in Vista, Windows 7, and Windows 8 Safely Remove Hardware allows you to safely shutdown and eject a storage device before just unplugging or disconnecting it to help prevent accidental data loss if data were still being copied or saved to or from...
How to manualy create a custom shortcut?
Hi, I want to create a custom shortcut and by custom I don't mean the way you usually create shortcuts at, but how you create it from scratch. Like open notepad and write down a script to make it work like an ordinary shortcut. The reason I want to do this is because I have a large collection of...
General Discussion
Desktop Background Shortcut - Create
How to Create a Change "Desktop Background" Shortcut in Vista and Windows 7 This will show you how to create or download a change Desktop Background shortcut to change your desktop background to either a wallpaper picture (image), solid color, or slideshow (Windows 7 only) of you choice in...
Create shortcut to themes? (on desktop)
Hello, I am running windows 7 on a laptop, and I was wondering if its possible to create shortcuts to themes. Reason for this is that I want my own made theme when I'm on netpower, but when I'm on battery only I want to switch to another theme (high contrast for example) to save battery power...
Themes and Styles

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 09:39.
Twitter Facebook