rudi Posted September 30, 2018 Share Posted September 30, 2018 Hello, I'd like to determine, "from what shortcut" a compiled autoit script was run. The background is, that several script versions shall be consolidated, an I have no clue, where the users might have placed fileshortcuts to oboslete old script verion names. eg. MyScript.exe, MyScript-1.exe MyScript-2.5.exe And shortcuts might be placed on the userdesktop, alluserdesktop, startup folder or somewhere else in the Start Menu. What I've found so far is the function _WinAPI_GetStartupInfo(). The helpfile is just pointing to MSDN without giving any examples... it's returning a "DLLstruct" -- howto retrieve further info from that type of variable? #include <WinAPISys.au3> #include <Debug.au3> $StartupInfo=_WinAPI_GetStartupInfo() $VarType=VarGetType($StartupInfo) if IsArray($StartupInfo) Then _DebugArrayDisplay($StartupInfo,$VarType) Else MsgBox(0,$VarType,"""" & $StartupInfo & """") EndIf Or maybe there is a better, different approach to get what shortcut from a compiled autoit script was started from? Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted September 30, 2018 Share Posted September 30, 2018 13 minutes ago, rudi said: Or maybe there is a better, different approach to get what shortcut from a compiled autoit script was started from? Never used, but maybe FileGetShortcut() could be a possible solution JLogan3o13 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Danp2 Posted September 30, 2018 Share Posted September 30, 2018 There's this basic example -- Then there's this information on Microsoft -- https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/ns-processthreadsapi-_startupinfoa Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
rudi Posted September 30, 2018 Author Share Posted September 30, 2018 Hello, thanks for your replies. @FrancescoDiMuro FileGetShortcut() doesn't help, as I don't need to extract information from a known LNK file, but I need to retrieve the unknown location of the link file, that was used to start a compiled script. @Danp2 That might be the right direction: #include <WinAPISys.au3> #include <Debug.au3> $tStartupInfo=_WinAPI_GetStartupInfo() $VarType=VarGetType($tStartupInfo) $StartupInfoString="" For $i = 1 To 18 $StartupInfoString &= $i & " = " & DllStructGetData($tSTARTUPINFO, $i) & @CRLF Next MsgBox(0,"startup info",$StartupInfoString) How did your know that there are 18 elements in the returned DLLStuct variable? The information I can retrieve with this function unfortunately doesn't help to know, where the "calling LNK file" is located: Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
rudi Posted September 30, 2018 Author Share Posted September 30, 2018 Hello, I've just seen the function DllStructGetSize() it's returning "68", but just the 1st 18 seem to hold valid data? #include <WinAPISys.au3> #include <Debug.au3> $tStartupInfo=_WinAPI_GetStartupInfo() $VarType=VarGetType($tStartupInfo) $StructSize=DllStructGetSize($tStartupInfo) $StartupInfoString="DllStructGetSize = " & $StructSize & @CRLF & "-----------------------------" For $i = 1 To $StructSize $StartupInfoString &= @CRLF & $i & " = " & DllStructGetData($tSTARTUPINFO, $i) if @error Then $StartupInfoString &= " @error = " & @error Next MsgBox(0,"startup info",$StartupInfoString) Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Danp2 Posted September 30, 2018 Share Posted September 30, 2018 You need to read the link I posted before from Microsoft. It outlines the _STARTUPINFOA structure and it's contents. 15 minutes ago, rudi said: I've just seen the function DllStructGetSize() it's returning "68", but just the 1st 18 seem to hold valid data? That's the size in bytes, not elements. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
rudi Posted September 30, 2018 Author Share Posted September 30, 2018 (edited) yes, I did read that in the help file. Seems the "Elements" are not the bytes, but some kind of "sub-structure"? So how to know the number of elements and *THEIR* size and type? Regards, Rudi. <edit> Type should be this one? Size? Howto resolve the values pointer elements point to? #include <WinAPISys.au3> #include <Debug.au3> $tStartupInfo=_WinAPI_GetStartupInfo() $VarType=VarGetType($tStartupInfo) $StructSize=DllStructGetSize($tStartupInfo) $StartupInfoString="DllStructGetSize = " & $StructSize & @CRLF & "-----------------------------" For $i = 1 To 18 ; $StructSize $NextElement=DllStructGetData($tSTARTUPINFO, $i) $StartupInfoString &= @CRLF & $i & " = " & $NextElement & ", VarType = " & VarGetType($NextElement) if @error Then $StartupInfoString &= " @error = " & @error Next MsgBox(0,"startup info",$StartupInfoString) Edited September 30, 2018 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Danp2 Posted September 30, 2018 Share Posted September 30, 2018 https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/ns-processthreadsapi-_startupinfoa Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
rudi Posted September 30, 2018 Author Share Posted September 30, 2018 Hi Dan. thanks for your reply. Honestly, the description at docs.microsoft.com doesn't help me at all to figure out, how to grab the information I'm looking for, that's basically to know, what "call" started "this instance of a compiled autoit script. Especially what was the LNK (FileShortcut) used to do so. And once more, the question, how to get hold of the information the poiters within the elements of the DllStruct point to? Regards, Rudi. typedef struct _STARTUPINFOA { DWORD cb; LPSTR lpReserved; LPSTR lpDesktop; LPSTR lpTitle; DWORD dwX; DWORD dwY; DWORD dwXSize; DWORD dwYSize; DWORD dwXCountChars; DWORD dwYCountChars; DWORD dwFillAttribute; DWORD dwFlags; WORD wShowWindow; WORD cbReserved2; LPBYTE lpReserved2; HANDLE hStdInput; HANDLE hStdOutput; HANDLE hStdError; } STARTUPINFOA, *LPSTARTUPINFOA; Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
rudi Posted October 4, 2018 Author Share Posted October 4, 2018 Bump: Any further suggestions, howto determine, *WHAT LNK FILE* was used to start "this-instance-of-a-running-autoit-script" ??? (compiled) TIA, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Jfish Posted October 4, 2018 Share Posted October 4, 2018 (edited) How about _WinAPI_GetProcessFileName ? It needs the PID but returns the fully-qualified path to the file. *EDIT* :L just realized you may need the actual shortcut as opposed to where the exe is located. Edited October 4, 2018 by Jfish FrancescoDiMuro 1 Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
rudi Posted October 5, 2018 Author Share Posted October 5, 2018 @Jfish Exactly. Maybe the function ... _WinAPI_GetStartupInfo() ... is the right approach, it's returning a DLLSTRUCT, holding several pointer elements, as @Danp2 pointed out some posts above. Well, I fail to figure out how to address the data these pointers point to. Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Deye Posted October 5, 2018 Share Posted October 5, 2018 Hi rudi, have you tried looking into _WinAPI_QueryInformationJobObject (check the help file example ) then find away to read its array output I tried looking into it a bit but I'm not very familiar with object manipulations .. Deye 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