Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Paint.NET Shortcut


  • Please log in to reply
1 reply to this topic
sbc
  • Members
  • 321 posts
  • Last active: Jun 07 2011 10:24 AM
  • Joined: 25 Aug 2009
Is anybody using Paint.Net on Window 7 64bit? I've found something odd with a Paint.NET shortcut file.

When I use the Run command by setting the path directly to the executable (e.g. Run, "C:\Program Files\Paint.NET\PaintDotNet.exe"), it works fine. However, if I set the path to the lnk file, it will fail (e.g. Run, "C:\Users\Public\Desktop\Paint.NET.lnk"). This does not happen on other applications. If I type the link such as "C:\Users\Public\Desktop\Paint.NET.lnk" via Run(Windows key + r), it just runs fine.

Also FileGetShortcut retrieves the wrong path from the link file of Paint.Net.

PaintDotNet_lnk := A_DesktopCommon . "\Paint.NET.lnk"
FileGetShortcut, %PaintDotNet_lnk%, PaintDotNet_Target
msgbox % PaintDotNet_Target
The code above shows this path, "C:\Program Files (x86)\Paint.NET\PaintDotNet.exe," despite the fact that the correct path is "C:\Program Files\Paint.NET\PaintDotNet.exe."

If anybody has this problem or a solution to retrieve the correct path, let me know. The code below demonstrates the problem. Thanks.
#Noenv
#singleinstance, Force
#persistent
SetWorkingDir %A_ScriptDir%

PaintDotNet := "C:\Program Files\Paint.NET\PaintDotNet.exe"
PaintDotNet_lnk := A_DesktopCommon . "\Paint.NET.lnk"
FileGetShortcut, %PaintDotNet_lnk%, PaintDotNet_Target
Return

^1::	;works
	Run, "%PaintDotNet%",,UseErrorLevel, pid
	if ErrorLevel
		msgbox Error: %PaintDotNet%
	else 
		msgbox %pid%
Return
^2::	;does not work
	IfExist, %PaintDotNet_lnk%
	{
		Run, "%PaintDotNet_lnk%",,UseErrorLevel, pid
		if ErrorLevel
			msgbox Error: %PaintDotNet_lnk%
		else 
			msgbox %pid%
	}
Return
^3::	;does not work. Somehow the retrieved path contains "(x86)" in it.
	Run, "%PaintDotNet_Target%",,UseErrorLevel, pid
	if ErrorLevel
		msgbox Error: %PaintDotNet_Target%
	else 
		msgbox %pid%

Return
^4::	;does not work
;	Run, %comspec% /c "C:\Users\Public\Desktop\Paint.NET.lnk",,UseErrorLevel, pid	;this doesn't work either
	Run, %comspec% /c "%PaintDotNet_lnk%",,UseErrorLevel, pid
	if ErrorLevel
		msgbox Error: %PaintDotNet_lnk%
	else 
		msgbox %pid%
Return


sbc
  • Members
  • 321 posts
  • Last active: Jun 07 2011 10:24 AM
  • Joined: 25 Aug 2009
Some other forum posts report ShellExecuteA works but it does not work on my computer. This did the trick.

DllCall("shell32\[color=darkred]ShellExecute[/color]", "uint", 0, "uint", 0
		, "str", A_DesktopCommon . "\Paint.NET.lnk" ; path of file
		, "str", ""  ; arguments
		, "uint", 0, "int", 1)