Jump to content

Homes32

Active Members
  • Posts

    56
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Homes32's Achievements

  1. Thank you all for the replies. Since my script that needs to listen ENV updates from external applications and is the parent process for other applications restarting it is not an option (it's a shell loader), I ended up just listening for WM_SETTINGCHANGE myself and querying the registry directly in order to perform a EnvSet() and EnvUpate() to update the "Local process" environment and push down any Env changes to @TempDir and to child processes as well. GUIRegisterMsg($WM_SETTINGCHANGE, "WindowProc") Func WindowProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_SETTINGCHANGE If $lParam <> 0 Then $ilParamStringLen = _WinAPI_StrLen($lParam) $lParamString = DllStructCreate("wchar[" & $ilParamStringLen & "]", $lParam) $sString = DllStructGetData($lParamString, 1) If $sString = "Environment" Then Local $sTmpDir = RegRead("HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment", "TMP") Local $sTempDir = RegRead("HKLM\SYSTEM\ControlSet001\Control\Session Manager\Environment", "TEMP") EnvSet("TMP", $sTmpDir) EnvSet("TEMP", $sTempDir) EnvUpdate() ConsoleWrite("Env Change: Temp=" & @TempDir) EndIf EndIf EndSwitch EndFunc
  2. Not quite. the question was specifically regarding updating the RUNNING script, not sub scripts. EnvUpdate() only updates child applications with the parent processes ENV, and in this case the PARENT is the ENV that needs to listen for Broadcasts from other applications.
  3. For example, when a program Run by the script changed %TEMP% and calls SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment") EnvGet() and @TempDir do not update to the new value, causing the next couple programs Run by the script to receive the wrong environment. According to the help docs and forum searches @TempDir is determined by GetTempPath(). Clearly EnvGet() is also not actually querying the event vars each time it is called, and just uses the value as of script start. Is there a method/option to force a running script to update EnvVars when a WM_SETTINGCHANGE message is received other then registering the WM_SETTINGCHANGE message and directly reading the registry and maintaining my own $TempDir variable? (Remember EnvGet() returns the old value as well)? Thanks! Homes32
  4. download link is broken.
  5. very nice tool. thanks for sharing!
  6. its very similar to capture.I have updated the example code in the first post with a basic Apply function.
  7. don't know how up2date this all is but here is some source code for the tools. last updated Dec 12, 2011 http://www.autoitscript.com/autoit3/files/beta/autoit/autoit-docs-v3.3.7.23-src.exe
  8. 3.07w to update replace upx.exe in C:\Program Files (x86)\AutoIt3\Aut2Exe\ or on x64 OS C:\Program Files (x86)\AutoIt3\Aut2Exe\ with the new version.
  9. the orange text looks nice but I think the old black was easier to read on the white background.
  10. forgot to upload v3 with fixed _WIM_GetImageInformation thanks JFX for helping figure this out!
  11. sorry. but currently the limitations of Autoit's callback implementation prevent this from working correctly. I'm sure it also doesn't help that the apply functions of wimgapi.dll are multi-threaded. as far as I know nobody has every gotten the progress to work with /apply
  12. Hi LaCastiglione, thanks for replying. I tried something like this already. the Crash actually occurs During DllStructGetData($xml, 1) so local_free($xml) will never be called. oops. my bad. just add $Percent as Global at the top. I also updated the sample code to fix this. thanks. Homes32
  13. * updated above post to hopefully provide more information for anybody willing to help figure this out. *
  14. I've run into an issue with getting info from a wim image. Autoit will crash and the windows event log will always show Exception code: 0xc0000005 which is a Access Violation error. tracing the _WIM_GetImageInformation func it always crashes at this line Func _WIM_GetImageInformation($hImage) Local $aReturn[2] ; array to hold the return data Local $ppvImageInfo = DllStructCreate("ptr") ; Buffer for XML Data Local $pcbImageInfo = DllStructCreate("int") ; Size of buffer in bytes Local $aResult = DllCall($ghwimgapi, "bool", "WIMGetImageInformation", _ "handle", $hImage, _ "ptr", DllStructGetPtr($ppvImageInfo), _ "ptr", DllStructGetPtr($pcbImageInfo)) If @error Then Return SetError(@error, @extended, 0) ; create a struct so we have access to the buffer where the XML data is stored Local $xml = DllStructCreate("wchar [" & DllStructGetData($pcbImageInfo, 1) & "]", DllStructGetData($ppvImageInfo, 1)) $aReturn[0] = $aResult[0] $aReturn[1] = DllStructGetData($xml, 1) ; <-- ***CRASH OCCURES HERE*** Return SetError(@error, _WinAPI_GetLastError(), $aReturn) EndFunc ;==>_WIM_GetImageInformation according to the return codes the structs get created correctly and the size of $xml is always correct, yet quite regularly reading data from $xml fails miserably. this doesn't happen every time the command is run but you can always reproduce by running the script several times in a row. the frequency seems random. can anyone give me some insite as to what may be going wrong here? some code to get everything up and running for anyone wanting to take a crack at this. make sure to download the UDF from the above link. thanks. Homes32 Steps to Reproduce If required change the path to the WIM file. In my tests the crashes were not specific to any particular WIM file. Run the following code several times in a row using F5 from SCITE or compile the code and use a cmd/bat to run several times in a row. It doesn't matter if you compile or use x68 vs x64, autoit will always have a hard crash at a seemingly random interval. Test code: #include <Wimgapi.au3> ; functions for WIM Global $swimfile, $hWim, $hImage, $filepath, $rTime, $pCallBack Global $gsWimDLL = @SystemDir & "\wimgapi.dll" ; path to wimgapi.dll $ProgramName = "WIM Demo" ; Fire up wimgapi.dll $aResult = _WIM_Startup() If @error = 2 Then MsgBox(16, $ProgramName, "Error loading library: " & "(" & $aResult & "," & @error & ", " & $gsWimDLL & ")" & @CRLF & @CRLF & "The file could not be found.") Exit (2) ElseIf @error = 1 Then MsgBox(16, $ProgramName, "Error loading library: " & "(" & $aResult & "," & @error & ", " & $gsWimDLL & ")" & @CRLF & @CRLF & "Wrong DLL. Make sure you are using the right arch (x86/x64)") Exit (254) EndIf GetInfo("C:\Images\Win7_32_EN_DVD\SOURCES\BOOT.WIM") ; Change this path to your WIM file ; GetInfo ;----------------------------- Func GetInfo($sWimFile) ; load .wim file with read access $hWim = _WIM_CreateFile($sWimFile, $WIM_GENERIC_READ, $WIM_OPEN_EXISTING, 0, 0, 0) If $hWim = 0 Then MsgBox(48, $ProgramName, "Error: Failed to load image. (" & $hWim & "," & @error & "," & @extended & ")") Cleanup() Exit (252) EndIf ; set our temp path $aResult = _WIM_SetTemporaryPath($hWim, @TempDir) ; read wim attributes $aWimAttribs = _WIM_GetImageAttributes($hWim) ; read info from the image $aXML = _WIM_GetImageInformation($hWim) ; Cleanup any open handles Cleanup() ; make our output pretty Switch $aWimAttribs[4] Case $WIM_COMPRESS_NONE $aWimAttribs[4] = "NONE" Case $WIM_COMPRESS_XPRESS $aWimAttribs[4] = "XPRESS" Case $WIM_COMPRESS_LZX $aWimAttribs[4] = "LZX" EndSwitch Local $outFile = @ScriptDir & "\wiminfo.txt" If FileExists($outFile) Then FileDelete($outFile) FileWrite($outFile, @CRLF & $ProgramName & @CRLF & @CRLF & @CRLF & @CRLF & _ "WIM Information:" & @CRLF & _ "----------------" & @CRLF & _ "Wim Path: : " & $aWimAttribs[1] & @CRLF & _ "GUID : " & $aWimAttribs[2] & @CRLF & _ "Image Count: " & $aWimAttribs[3] & @CRLF & _ "Compression: " & $aWimAttribs[4] & @CRLF & _ "Part Number: " & $aWimAttribs[5] & "/" & $aWimAttribs[6] & @CRLF & _ "Boot Index : " & $aWimAttribs[7] & @CRLF & _ "Attributes : " & $aWimAttribs[8] & @CRLF & @CRLF & @CRLF & _ "Available Image Choices:" & @CRLF & _ "------------------------" & @CRLF & _ $aXML[1]) EndFunc ;==>GetInfo Func Cleanup() ; Cleanup any open handles If $hImage Then _WIM_CloseHandle($hImage) If $hWim Then _WIM_CloseHandle($hWim) If $pCallBack Then ; Cleanup our callbacks $aResult = _WIM_UnregisterMessageCallback(0, DllCallbackGetPtr($pCallBack)) DllCallbackFree($pCallBack) EndIf _WIM_Shutdown() ; shutdown wimgapi.dll EndFunc ;==>Cleanup
  15. thanks for keeping this great UDF up!
×
×
  • Create New...