mespork Posted August 19, 2009 Share Posted August 19, 2009 Hello, I need help with checking to see if a directory exists. The problem is that the directory will change depending on the computer. Here is what I have FileFindFirstFile($vartemp&"\_AI*.tmp") However, it is still returning -1 even though there is a folder named _AIB361.tmp in the directory (%temp% on the machine which $vartemp is set to) Thanks David Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 19, 2009 Share Posted August 19, 2009 (edited) Hello, I need help with checking to see if a directory exists. The problem is that the directory will change depending on the computer. Here is what I have FileFindFirstFile($vartemp&"\_AI*.tmp") However, it is still returning -1 even though there is a folder named _AIB361.tmp in the directory (%temp% on the machine which $vartemp is set to) Thanks David Post exactly how you set the value in $vartemp. You could put a debug point in there like this: $sFilePath = $vartemp & "\_AI*.tmp" MsgBox(64, "Debug", "$sFilePath = " & $sFilePath) $hFinder = FileFindFirstFile($sFilePath) If $hFinder = -1 Then MsgBox(16, "Error", "FileFindFirstFile() failed") Exit EndIf >_< Edited August 19, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 19, 2009 Moderators Share Posted August 19, 2009 mespork, First, welcome to the Autoit forums. You need to use the FileExists function to determine whether your folder exists. FileFindFirstFile needs a full path and filename (which can include wildcards) to return a search handle for further exploitation - hardly surprising that it returns -1 in this case!. >_< Of course, FileFindFirstFile might well come in handy if you want to search the level above for all the folders which meet the mask you have set (_AI*.tmp[/i1]) and you want to choose between them. M23 PS. In the longer term, You might find that reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mespork Posted August 19, 2009 Author Share Posted August 19, 2009 mespork, First, welcome to the Autoit forums. You need to use the FileExists function to determine whether your folder exists. FileFindFirstFile needs a full path and filename (which can include wildcards) to return a search handle for further exploitation - hardly surprising that it returns -1 in this case!. >_< Of course, FileFindFirstFile might well come in handy if you want to search the level above for all the folders which meet the mask you have set (_AI*.tmp[/i1]) and you want to choose between them. M23 PS. In the longer term, You might find that reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here. After working trough it a couple of times I have it now reconizing that there is a folder there. However, the folder is gone it is not starting the next program. Here is my program, it is a pretty simple one: $vartemp = EnvGet("temp") $search = FileFindFirstFile($vartemp&"\_AI*.tmp") Run("\\cazapp01\Apps\Autodesk\32\2010\AdminImage\setup.exe /qb /I \\cazapp01\Apps\Autodesk\32\2010\AdminImage\AutoCad_Apple.ini /language en-us", "\\cazapp01\Apps\Autodesk\32\2010\AdminImage") Do Sleep(50000) FileClose($search) $search = FileFindFirstFile($vartemp&"\_AI*.tmp") MsgBox(4096,"Search", $search) Until $search == -1 Run("\\cazapp01\Apps\Autodesk\32\2010\Architecture\AdminImage\setup.exe /qb /I \\cazapp01\Apps\Autodesk\32\2010\Architecture\AdminImage\Architecture_Apple.ini /language en-us", "\cazapp01\Apps\Autodesk\32\2010\AdminImage") Do Sleep(50000) FileClose($search) $search = FileFindFirstFile($vartemp&"\_AI*.tmp") MsgBox(4096,"Search", $search) Until $search == -1 Run("\\cazapp01\Apps\Autodesk\32\2010\3DsMax\AdminImage\setup.exe /qb /I \\cazapp01\Apps\Autodesk\32\2010\3DsMax\AdminImage\3DsMax_Apple.ini", "\\cazapp01\Apps\Autodesk\32\2010\3DsMax\AdminImage") Do FileClose($search) $search = FileFindFirstFile($vartemp&"\_AI*.tmp") MsgBox(4096,"Search", $search) Until $search == -1 I am just trying to make an install for our AutoCad suite. David Link to comment Share on other sites More sharing options...
mespork Posted August 20, 2009 Author Share Posted August 20, 2009 Is there anything I am missing with the run command, should I pass it to a command prompt? David Link to comment Share on other sites More sharing options...
bo8ster Posted August 20, 2009 Share Posted August 20, 2009 I would try dropping the working directory param Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
mespork Posted August 20, 2009 Author Share Posted August 20, 2009 I would try dropping the working directory paramGood idea. I will try when I get to work.David Link to comment Share on other sites More sharing options...
mespork Posted August 21, 2009 Author Share Posted August 21, 2009 Getting rid of the working directory and it worked. Thank you!!! 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