<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=IShellLink_Set_RunAs_flag</id>
	<title>IShellLink Set RunAs flag - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://nsis.sourceforge.io/mediawiki/index.php?action=history&amp;feed=atom&amp;title=IShellLink_Set_RunAs_flag"/>
	<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=IShellLink_Set_RunAs_flag&amp;action=history"/>
	<updated>2026-04-22T19:21:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://nsis.sourceforge.io/mediawiki/index.php?title=IShellLink_Set_RunAs_flag&amp;diff=18580&amp;oldid=prev</id>
		<title>Anders: Created page with &#039;{{PageAuthor|Anders}}  This code sets the &quot;Run with different credentials&quot; property on a shortcut (.lnk)  &lt;highlight-nsis&gt; !include LogicLib.nsh  !ifndef IPersistFile !define IPe…&#039;</title>
		<link rel="alternate" type="text/html" href="https://nsis.sourceforge.io/mediawiki/index.php?title=IShellLink_Set_RunAs_flag&amp;diff=18580&amp;oldid=prev"/>
		<updated>2010-06-03T15:49:04Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;{{PageAuthor|Anders}}  This code sets the &amp;quot;Run with different credentials&amp;quot; property on a shortcut (.lnk)  &amp;lt;highlight-nsis&amp;gt; !include LogicLib.nsh  !ifndef IPersistFile !define IPe…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{PageAuthor|Anders}}&lt;br /&gt;
&lt;br /&gt;
This code sets the &amp;quot;Run with different credentials&amp;quot; property on a shortcut (.lnk)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;&lt;br /&gt;
!include LogicLib.nsh&lt;br /&gt;
&lt;br /&gt;
!ifndef IPersistFile&lt;br /&gt;
!define IPersistFile {0000010b-0000-0000-c000-000000000046}&lt;br /&gt;
!endif&lt;br /&gt;
!ifndef CLSID_ShellLink&lt;br /&gt;
!define CLSID_ShellLink {00021401-0000-0000-C000-000000000046}&lt;br /&gt;
!define IID_IShellLinkA {000214EE-0000-0000-C000-000000000046}&lt;br /&gt;
!define IID_IShellLinkW {000214F9-0000-0000-C000-000000000046}&lt;br /&gt;
!define IShellLinkDataList {45e2b4ae-b1c3-11d0-b92f-00a0c90312e1}&lt;br /&gt;
	!ifdef NSIS_UNICODE&lt;br /&gt;
	!define IID_IShellLink ${IID_IShellLinkW}&lt;br /&gt;
	!else&lt;br /&gt;
	!define IID_IShellLink ${IID_IShellLinkA}&lt;br /&gt;
	!endif&lt;br /&gt;
!endif&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Function ShellLinkSetRunAs&lt;br /&gt;
System::Store S&lt;br /&gt;
pop $9&lt;br /&gt;
System::Call &amp;quot;ole32::CoCreateInstance(g&amp;#039;${CLSID_ShellLink}&amp;#039;,i0,i1,g&amp;#039;${IID_IShellLink}&amp;#039;,*i.r1)i.r0&amp;quot;&lt;br /&gt;
${If} $0 = 0&lt;br /&gt;
	System::Call &amp;quot;$1-&amp;gt;0(g&amp;#039;${IPersistFile}&amp;#039;,*i.r2)i.r0&amp;quot; ;QI&lt;br /&gt;
	${If} $0 = 0&lt;br /&gt;
		System::Call &amp;quot;$2-&amp;gt;5(w &amp;#039;$9&amp;#039;,i 0)i.r0&amp;quot; ;Load&lt;br /&gt;
		${If} $0 = 0&lt;br /&gt;
			System::Call &amp;quot;$1-&amp;gt;0(g&amp;#039;${IShellLinkDataList}&amp;#039;,*i.r3)i.r0&amp;quot; ;QI&lt;br /&gt;
			${If} $0 = 0&lt;br /&gt;
				System::Call &amp;quot;$3-&amp;gt;6(*i.r4)i.r0&amp;quot; ;GetFlags&lt;br /&gt;
				${If} $0 = 0&lt;br /&gt;
					System::Call &amp;quot;$3-&amp;gt;7(i $4|0x2000)i.r0&amp;quot; ;SetFlags ;SLDF_RUNAS_USER&lt;br /&gt;
					${If} $0 = 0&lt;br /&gt;
						System::Call &amp;quot;$2-&amp;gt;6(w &amp;#039;$9&amp;#039;,i1)i.r0&amp;quot; ;Save&lt;br /&gt;
					${EndIf}&lt;br /&gt;
				${EndIf}&lt;br /&gt;
				System::Call &amp;quot;$3-&amp;gt;2()&amp;quot; ;Release&lt;br /&gt;
			${EndIf}&lt;br /&gt;
		System::Call &amp;quot;$2-&amp;gt;2()&amp;quot; ;Release&lt;br /&gt;
		${EndIf}&lt;br /&gt;
	${EndIf}&lt;br /&gt;
	System::Call &amp;quot;$1-&amp;gt;2()&amp;quot; ;Release&lt;br /&gt;
${EndIf}&lt;br /&gt;
push $0&lt;br /&gt;
System::Store L&lt;br /&gt;
FunctionEnd&lt;br /&gt;
&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;highlight-nsis&amp;gt;&lt;br /&gt;
CreateShortcut &amp;quot;$temp\test.lnk&amp;quot; &amp;quot;calc.exe&amp;quot;&lt;br /&gt;
push &amp;quot;$temp\test.lnk&amp;quot;&lt;br /&gt;
call ShellLinkSetRunAs&lt;br /&gt;
pop $0&lt;br /&gt;
DetailPrint HR=$0&lt;br /&gt;
&amp;lt;/highlight-nsis&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Disk, Path &amp;amp; File Functions]]&lt;/div&gt;</summary>
		<author><name>Anders</name></author>
	</entry>
</feed>