goldenix Posted April 26, 2008 Posted April 26, 2008 (edited) if I run or build & then run my exe via Double clicking on it, then its all working fineim using vb.exe to launch my exe written in autoit, so it can read some text from *.txt fileBut if I use visual basic to open my _deadlinkscheck.exe file, then vb.exe starts _deadlinkscheck.exe & then I get this error: Unable to open _deadlinks_temp. obviously there is no error in my vb.net code. the queston is Why cant my autoit script open the file, or is there a way to check what is causing the error ?btw what does If $file = -1 Then mean?vb.code:Shell(My.Computer.FileSystem.CurrentDirectory & "\_deadlinkscheck.exe")$file = FileOpen("_deadlinks_temp", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open _deadlinks_temp") Exit EndIf FileClose($file)EDIT See posts 9 & 13 for solution Edited April 26, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
flip209 Posted April 26, 2008 Posted April 26, 2008 (edited) try using the full path to open the file Edit: More then likely it can not find "_deadlinks_temp", also you are opening this in read only. So maybe this file does not exist... Edited April 26, 2008 by flip209 " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln
goldenix Posted April 26, 2008 Author Posted April 26, 2008 (edited) try using the full path to open the fileEdit: More then likely it can not find "_deadlinks_temp", also you are opening this in read only. So maybe this file does not exist...As I said, all works fine, if I double klick my _deadlinkscheck.exe file. this means the file is there & there is some text in it also.its the same whether I use full filepath or with @scriptdir I get same error Edited April 26, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
MHz Posted April 26, 2008 Posted April 26, 2008 btw what does If $file = -1 Then mean?$file is the variable storing the handle returned from the FileOpen function. If it stores -1 then FileOpen failed to get a handle thus the file is already has a handle open by another program or some other issue. Try using this code within _deadlinkscheck.exe and see what it informs you. MsgBox(0x40000, '@WorkingDir', @WorkingDir) If Not FileExists('_deadlinks_temp') And FileExists(@ScriptDir & '\_deadlinks_temp') Then If FileChangeDir(@ScriptDir) Then MsgBox(0x40000, 'FileChangeDir', @WorkingDir) If FileExists('_deadlinks_temp') Then MsgBox(0x40000, 'FileExists', @WorkingDir & '\_deadlinks_temp') Else MsgBox(0x40030, 'FileExists', 'Failed to find ' & @WorkingDir & '\_deadlinks_temp') EndIf Else MsgBox(0x40030, 'FileChangeDir', 'Failed to change to ' & @ScriptDir) EndIf ElseIf FileExists('_deadlinks_temp') Then MsgBox(0x40000, 'FileExists', @WorkingDir & '\_deadlinks_temp') Else MsgBox(0x40030, 'FileExists', 'Failed to find ' & @WorkingDir & '\_deadlinks_temp') EndIf
goldenix Posted April 26, 2008 Author Posted April 26, 2008 Try using this code within _deadlinkscheck.exe and see what it informs you this is what I get: using RUN: ----------- @WorkingDir C:\test FileExists C:\test\_deadlinks_temp Doubleclick: ----------- @WorkingDir C:\test FileExists C:\test\_deadlinks_temp Using: Shell("_deadlinkscheck.exe") --------------------------------- @WorkingDir C:\test FileExists C:\test\_deadlinks_temp My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
MHz Posted April 26, 2008 Posted April 26, 2008 FileExists finds it OK and the working directory is OK so the file must be already opened with a handle or some other issue. If your VB application creates or uses the file then make sure it closes the handle so the AutoIt script can read from it. I am not sure of any further advice to give. You could try to manually delete the file to recycle bin when the error pops up and see if another error appears of failing to delete which tells you that a handle is already open to the file which makes the AutoIt script fail with reason.
goldenix Posted April 26, 2008 Author Posted April 26, 2008 (edited) FileExists finds it OK and the working directory is OK so the file must be already opened with a handle or some other issue. If your VB application creates or uses the file then make sure it closes the handle so the AutoIt script can read from it. I am not sure of any further advice to give. You could try to manually delete the file to recycle bin when the error pops up and see if another error appears of failing to delete which tells you that a handle is already open to the file which makes the AutoIt script fail with reason. my VB app olny purpose is to launch _deadlinkscheck.exe, therefore it has only 1 line of code in it.see first post. When that msbox pops out with the Unable to open _deadlinks_temp, I had no problems deleting _deadlinks_temp. I did more experimenting with code below, I found out, that if i use my vb.app to start _deadlinkscheck.exe, then File NOT found messagebox pops out, How is this possible? if fileexists('_deadlinks_temp') Then MsgBox(0, "", "File found") Else MsgBox(0, "", "File NOT found") EndIf well I attachecd the files feel like to take a look em? VBapp_launcher.exe is the vb launcertest.rar Edited April 26, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
flip209 Posted April 26, 2008 Posted April 26, 2008 Ok, after looking at you example. VB is giving you the error, not au3 and you are calling a .exe that is not there... " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln
MHz Posted April 26, 2008 Posted April 26, 2008 well I attachecd the files feel like to take a look em? VBapp_launcher.exe is the vb launcerThanks for the test files. You are executing the AutoIt compiled script from another directory in the test structure so the working directory may not the same as where the script is. You may need to set the working directory for the AutoIt script execution or set the working directory within the AutoIt script or use a valid path (relative or absolute) for FileOpen(). This works for me. FileChangeDir(@ScriptDir) if fileexists('_deadlinks_temp') Then MsgBox(0, "", "File found") _fileopen() Else MsgBox(0, "", "NOT found") EndIf func _fileopen() $file = FileOpen("_deadlinks_temp", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open _deadlinks_temp") Exit EndIf MsgBox(0, "", FileReadLine($file,1)) FileClose($file) EndFunc --------------------------- --------------------------- File found --------------------------- OK ------------------------------------------------------ --------------------------- http://www.megaupload.com/?d=7YEJPH5J --------------------------- OK ---------------------------
TomZ Posted April 26, 2008 Posted April 26, 2008 You should try using RunWait to wait for the EXE to exit, and then read the file.
flip209 Posted April 26, 2008 Posted April 26, 2008 This fixes it, like I said use the full path. You were calling the VB in a different directory. Which from all standards becomes the working directory unless other wise stated. All so fix your vb code instead of \config\_deadlinkscheck.exe it needs to be .\config\_deadlinkscheck.exe. I am not sure what your skill level is at but that fixes it for me. CODE if fileexists('C:\Documents and Settings\Philip Stacy\Desktop\test\config\_deadlinks_temp.txt') Then MsgBox(0, "", "File found") _open() Else MsgBox(0, "", "NOT found") EndIf func _open() $file = FileOpen("C:\Documents and Settings\Philip Stacy\Desktop\test\config\_deadlinks_temp.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open _deadlinks_temp") Exit EndIf MsgBox(0, "", FileReadLine($file,1)) FileClose($file) EndFunc " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln
flip209 Posted April 26, 2008 Posted April 26, 2008 LMAO that is funny sorry to repost. " I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln
goldenix Posted April 26, 2008 Author Posted April 26, 2008 (edited) This works for me.Yup this is really really weird sometimes it works & sometimes it does not.(I was just talking about my included files) but this aside your way does the work & even tho i tested it before & I was getting same error with the code below....well it seems to be working now, its a magic, what else can i say, exept that if it wont work for shure unless @scriptdir is used. Problem solved. Thank you. EDIT: Vb code was good like I said problem was in autoit. if fileexists(@ScriptDir & '\_deadlinks_temp') Then MsgBox(0, "", "File found") _fileopen() Else MsgBox(0, "", "NOT found") EndIf func _fileopen() $file = FileOpen(@ScriptDir & '\_deadlinks_temp', 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open _deadlinks_temp") Exit EndIf MsgBox(0, "", FileReadLine($file,1)) FileClose($file) EndFunc Edited April 26, 2008 by goldenix My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
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