Luigi Posted November 11, 2014 Share Posted November 11, 2014 (edited) 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? try_monitor.exe #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=C:\try_monitor.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Res_Fileversion=0.0.0.2 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y #AutoIt3Wrapper_Res_Language=1046 #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** HotKeySet("{F9}", "_quit") TraySetIcon("explorer.exe", 0) While Sleep(100) WEnd Func _quit() Exit EndFunc set_shortcut expandcollapse popup#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) Else ConsoleWrite("@ok" & @LF) EndIf 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" EndSwitch 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) EndSwitch If FileCreateShortcut($sFULL_PATH, $SHORTCUT, $sDrive & $sDir, "", "", $sFULL_PATH, "", $iIcon, @SW_SHOWMINNOACTIVE) Then Return 1 Else Return SetError(4, 0, 0) EndIf EndFunc ;==>install Edited November 11, 2014 by Detefon Visit my repository Link to comment Share on other sites More sharing options...
Luigi Posted November 11, 2014 Author Share Posted November 11, 2014 (edited) 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 #RequireAdmin But... not start the application on restart... Edited November 11, 2014 by Detefon Visit my repository Link to comment Share on other sites More sharing options...
Danyfirex Posted November 12, 2014 Share Posted November 12, 2014 You should use %appdata% + "RoamingMicrosoftWindowsStart MenuProgramsStartup" Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now