Jump to content
Sign in to follow this  

FileCreateShortcut, create shortcut, but not start on Win8

Recommended Posts


Hi forum, I write this function to put my application's shortcut in start menu.

I have machines with WinXP, Win7 and Win8.

The script put a shortcut in WinXP and 7 very well, and start the application too...

In Win 8, the script create the shortcut, but not start the application...

I thinking this is easy, but not... i miss something?

Compile 'try_monitor.exe' or set other file...

Then run set_shortcut

Someone can help me?

Obs: I need start the application for any user... (users that already exist and yet to be created)

I thinking is the best way is All Users/StartUp, write?


#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
HotKeySet("{F9}", "_quit")

TraySetIcon("explorer.exe", 0)
While Sleep(100)

Func _quit()


#include <Array.au3>
#include <File.au3>

;~ Local $var = @HomeDrive & "\Documents and Settings\All Users\Start Menu\Programs\Startup"
;~ ConsoleWrite( $var & @LF)

set_shortcut("C:\try_monitor.exe", "Try_Monitor", 3)
If @error Then
    ConsoleWrite("@error->" & @error & @LF)
    ConsoleWrite("@ok" & @LF)

Func set_shortcut($sFULL_PATH = 0, $sName = "", $iIcon = 0)
    ; WORK ON
    ; [+] work
    ; [-] does not work
    ; Windows 8.1.................[ ]
    ;      Windows 8.1 (32).......[ ]
    ;      Windows 8.1 (64).......[+]
    ; Windows 8 (generic).........[ ]
    ;      Windows 8 (32).........[ ]
    ;      Windows 8 (64).........[ ]
    ; Windows 7 (generic).........[ ]
    ;      Windows 7 (32).........[ ]
    ;      Windows 7 (64).........[+]
    ; Windows XP (generic)........[ ]
    ;      Windows Home...........[ ]
    ;      Windows Professional...[+]

    If Not FileExists($sFULL_PATH) Then Return SetError(1, 0, 0)
    Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
    Local $aPathSplit = _PathSplit($sFULL_PATH, $sDrive, $sDir, $sFilename, $sExtension)
    If @error Then Return SetError(2, 0, 0)

    If Not $sName Then $sName = $sFilename
    Local $SHORTCUT

    Switch @OSVersion
        Case "WIN_XP"
            Switch @OSLang
                Case 0416
                    $SHORTCUT = @HomeDrive & "\Documents and Settings\All Users\Menu Iniciar\Programas\Inicializar\" & $sName & ".lnk"
                Case Else
                    $SHORTCUT = @HomeDrive & "\Documents and Settings\All Users\Start menu\Programs\Start\" & $sName & ".lnk"
        Case "WIN_8", "WIN_81"
            $SHORTCUT = @AppDataDir & "\Microsoft\Windows\Start Menu\Programs\Startup\" & $sName & ".lnk"
            ConsoleWrite($SHORTCUT & @LF)
        Case "WIN_7"
            $SHORTCUT = @HomeDrive & "\Documents and Settings\All Users\Start Menu\Programs\Startup\" & $sName & ".lnk"
        Case Else
            Return SetError(3, 0, 0)

    If FileCreateShortcut($sFULL_PATH, $SHORTCUT, $sDrive & $sDir, "", "", $sFULL_PATH, "", $iIcon, @SW_SHOWMINNOACTIVE) Then
        Return 1
        Return SetError(4, 0, 0)
EndFunc   ;==>install
Edited by Detefon

Visit my repository

Share this post

Link to post
Share on other sites

Hum... I found the error!

Case "WIN_8", "WIN_81"
            $SHORTCUT = @HomeDrive & "\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\" & $sName & ".lnk"
            ConsoleWrite($SHORTCUT & @LF)

And missing


But... not start the application on restart...

Edited by Detefon

Visit my repository

Share this post

Link to post
Share on other sites

You should use %appdata% + "RoamingMicrosoftWindowsStart MenuProgramsStartup"



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.