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.
https://www.virustotal.com/en/file/6...is/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 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
Microsoft MVP

64-bit Windows 8.1 Enterprise
 
 

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

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
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.

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

64-bit Windows 8.1 Enterprise
 
 

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

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

64-bit Windows 8.1 Enterprise
 
 

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

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
Reply

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




Thread Tools



Similar help and support threads for2: Custom 'Desktop (create shortcut)' Remove .fileextension - Shortcut
Thread Forum
Show Desktop Shortcut - Create Tutorials
Safely Remove Hardware Shortcut - Create Tutorials
How to manualy create a custom shortcut? General Discussion
Desktop Background Shortcut - Create Tutorials
Create shortcut to themes? (on desktop) 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 11:00 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33