thepip3r Posted January 29, 2008 Share Posted January 29, 2008 When you right-click on a Windows shorcut, the "target" field usually dispalys the absolute path to the source file, but for some files, like Microsoft Office files and the Administrative Tools, the Target field is grayed out and says something else instead of a path -- almost like some sort of special shortcut. And I've tried passing the path with both Run and ShellExecute and ShellExecute gives me an error stating "parameter incorrect". Does anyone know how you'd actually get one of those files to execute? Or how to check for one of those special files so I can treat it differently? My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume Link to comment Share on other sites More sharing options...
Swift Posted January 29, 2008 Share Posted January 29, 2008 Could you give me an idea of what file your opening? like...Control panel? or anything like that...you can call a .dll...to open it....is that what your asking? Link to comment Share on other sites More sharing options...
therks Posted January 29, 2008 Share Posted January 29, 2008 (edited) When you right-click on a Windows shorcut, the "target" field usually dispalys the absolute path to the source file, but for some files, like Microsoft Office files and the Administrative Tools, the Target field is grayed out and says something else instead of a path -- almost like some sort of special shortcut. And I've tried passing the path with both Run and ShellExecute and ShellExecute gives me an error stating "parameter incorrect". Does anyone know how you'd actually get one of those files to execute? Or how to check for one of those special files so I can treat it differently?I'm not sure how to determine the path from the shortcut file, but one method you can use until someone comes along who can figure it out, is to just ShellExecute the shortcut file. Other than that you could just try and manually locate the .exe that the shortcuts point to.*Edit: And just for reference, I think the OP is talking about shortcuts that look like this: http://www.therks.com/public/wordshortcut.gif Edited January 29, 2008 by Saunders My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
thepip3r Posted January 29, 2008 Author Share Posted January 29, 2008 that pic is exactly right Saunders. And my problem is that when I pass the shortcut file (like the one u uploaded) to run or shellexecute, i get errors so I was just wondering if there was a way around this? My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume Link to comment Share on other sites More sharing options...
MrCreatoR Posted January 29, 2008 Share Posted January 29, 2008 Hi, I use this UDF to execute those kind of shortcuts: _ShellExecuteEx(@AppDataDir & "\Microsoft\Internet Explorer\Quick Launch\Microsoft Word.lnk") Func _ShellExecuteEx($sCmd, $sArgs = "", $sFolder = "", $sVerb = "", $iState = @SW_SHOWNORMAL, $hWnd = 0) Local $stINFO = DllStructCreate("long;long;long;ptr;ptr;ptr;ptr;long;long;long;ptr;long;long;long;long") Local $stVerb = DllStructCreate("char[15];char") Local $stPath = DllStructCreate("char[255];char") Local $stArgs = DllStructCreate("char[255];char") Local $stWDir = DllStructCreate("char[255];char") DllStructSetData($stVerb, 1, $sVerb) DllStructSetData($stPath, 1, $sCmd) DllStructSetData($stWDir, 1, $sFolder) DllStructSetData($stArgs, 1, $sArgs) DllStructSetData($stINFO, 1, DllStructGetSize($stINFO)) DllStructSetData($stINFO, 2, BitOR(0xC, 0x40, 0x400)) DllStructSetData($stINFO, 3, $hWnd) DllStructSetData($stINFO, 4, DllStructGetPtr($stVerb)) DllStructSetData($stINFO, 5, DllStructGetPtr($stPath)) DllStructSetData($stINFO, 6, DllStructGetPtr($stArgs)) DllStructSetData($stINFO, 7, DllStructGetPtr($stWDir)) DllStructSetData($stINFO, 8, $iState) Local $aRet = DllCall("shell32.dll", "int", "ShellExecuteEx", "ptr", DllStructGetPtr($stINFO)) If Not IsArray($aRet) Or Not $aRet[0] Then Return SetError(2, 0, 0) Return 1 EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
thepip3r Posted January 29, 2008 Author Share Posted January 29, 2008 Thanx Ms... that is exactly what I needed. My Additions:- RunAs AdminDeviant Fun:- Variable Sound Volume Link to comment Share on other sites More sharing options...
RegiOween Posted June 3, 2008 Share Posted June 3, 2008 Hi, folks! I tried the _ShellExecuteEx UDF function to start a shortcut to a dial-up connection that requires authentication, but strangely, if I don't put some sleep after the function call, the dial-up authentication screen doesn't appear, and if I put Sleep(5000), for example, the screen appear and close after 5 seconds. Is there some way to make it work without the wait? Thanks in advance. Reginald0 Link to comment Share on other sites More sharing options...
MrCreatoR Posted June 3, 2008 Share Posted June 3, 2008 Is there some way to make it work without the wait?Maybe try this: Run(@ComSpec & ' /c Start "" "Path\to\Dial-Up.lnk"', '', @SW_HIDE) Or look at the shortcut properties, is there some special CLSID? i think you could use that to execute it directly... or use RasDial... Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
RegiOween Posted June 4, 2008 Share Posted June 4, 2008 MrCreator, thanks for your tips. I have already tried the Run(@ComSpec...) alternative, but with the /c option it did nothing, and with /k option works, but open another CMD.EXE window that @SW_HIDE doesn't catch. The RasDial alternative is really functional, and in fact I was using it to circumvent the ShellExecuteEx problem, but I just don't understand why this function didn't work the way I was expecting, since it loads the DialUp connection, but if I don't put some sleep after the loaded screen, it closes immediatelly, and my impression is that the function itself is closing the process, because if I put 5 seconds of sleep, the screen closes right after that. Anyway, many thanks for your attention. Reginald0 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