Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 13 of 13
  1. #1
    Join Date
    Nov 2005
    Posts
    12

    Grin Questions about searching all fixed drives for a file

    Hi,
    I've been reading in the forums a bit and managed to find some snippets to assist me in my task. I'm trying to make a little exe that will:
    1. Find all fixed drives.
    2. search all fixed drives that were found for a single file.
    3. Overwrite that found file with a new one.

    I'm trying the file.find , but I don't kno what folder this file is going to be stored in. The user could've put it anywhere. From the snippets, I've managed the following code :
    Code:
    drivetbl = Drive.Enumerate();
    for drvindex, drives in drivetbl do
    drive_type = Drive.GetType(drives);
    if (drive_type == 3) then 
    appdirectory = File.Find(,"blah.exe",true,false,nil,nil);
    if (appdirectory ~= nil)  then 
    result = Dialog.Message("Notice", "" .. appdirectory[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    
    break;
    end
    end 
    end
    I know where I've left off is all messed up, but I don't know where to go from here. Any Help?

    Thanks

  2. #2
    Join Date
    Nov 2005
    Posts
    12
    By the way I forgot when I listed that code I had taken out the drive to search for. So I've put back in and listed it below. I know it's wrong, but it's what I'm aiming for.
    Code:
    drivetbl = Drive.Enumerate();
    for drvindex, drives in drivetbl do
    drive_type = Drive.GetType(drives);
    if (drive_type == 3) then 
    appdirectory = File.Find(drive_type,"blah.exe",true,false,nil,nil);
    if (appdirectory ~= nil)  then 
    result = Dialog.Message("Notice", "" .. appdirectory[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    
    break;
    end
    end 
    end
    I have the dialog message there just because I'm trying to see what the value would return and see when I get it right..which so far has proven difficult. :-) Thanks

  3. #3
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    Where you've left off, you have a table containing the locations of your file on the last drive searched...

    Code:
    replacement = "\\AutoPlay\\Docs\\myNewFile.ext";
    drivetbl = Drive.Enumerate();
    for drvindex, drives in drivetbl do
    drive_type = Drive.GetType(drives); if (drive_type == 3) then
    appdirectory = File.Find(drives,"blah.exe",true,false,nil,nil); if (appdirectory ~= nil) then
    result = Dialog.Message("Notice", "" .. appdirectory[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); for index, filename in appdirectory do
    File.Install(replacement, filename, 2, true);
    end
    end
    end
    end
    What we did here was add a File.Install() action into the loop so that as the search of each drive is complete, we replace any files found.
    Yeah right. Who's the only one here who knows the illegal ninja moves from the government?

    ()))))))))o)))))))==============================================

  4. #4
    Join Date
    Nov 2005
    Posts
    12
    After tinkering a bit, I got the find to work and find the file. I used the following.

    Code:
    tbDrives = Drive.Enumerate();
    for i,v in tbDrives do
    	if Drive.GetType(v) == DRIVE_FIXED then
    		tbFile = File.Find(v, "blah.exe", true, false, nil, nil);
    		if not tbFile then
    			else
    			File.Delete(""..tbFile[1], false, false, false, nil);
    				result = Dialog.Message("Notice", ""..tbFile[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    
    				break
               end
         end
    end
    Now the only problem is that the file I want to replace it with will be within the archive of the installer. I'm not quite sure how to pull that out and put in this files place.
    I went to the install directory screen and set the directory to tbFile[1] , but it doesn't like that at all. This is going to be a download install and not from CD btw..so I don't know how I'd use _source. I know I'm completely wrong on this, any more help?
    Thanks

  5. #5
    Join Date
    Nov 2005
    Posts
    12
    TJS
    I sure am glad you're seeing my messages, because you were the one that helped the last guy with something similar to this and you're where I found that first bit of code. I tried what you put in, but I still can't figure out how to point the replacement file to a file in the archive directory.
    Thanks

  6. #6
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    you should be able to add the file in question to the "Primer" files for the project and distribute them outside of the installer (maybe zip them together for download)... or you could leave the file replace operation until after the install is performed. That way the file you need will be extracted and available.
    Yeah right. Who's the only one here who knows the illegal ninja moves from the government?

    ()))))))))o)))))))==============================================

  7. #7
    Join Date
    Nov 2005
    Posts
    12
    Ok, so here's what I have so far.
    I decided to do like you said and install the file first to a temp directory ("C:\blahupdater") then as an action on "POST INSTALL" have do what I'm trying to do, but I keep getting an error saying "Invalid Source" What am I missing?

    Code:
    replacement = "C:\BlahUpdater\blah2.exe";
    drivetbl = Drive.Enumerate();
    for drvindex, drives in drivetbl do
    		drive_type = Drive.GetType(drives);
    		if (drive_type == 3) then
    			appdirectory = File.Find(drives,"blah.exe",true,false,nil,nil);
    			if (appdirectory ~= nil)  then 
    				result = Dialog.Message("Notice", "" .. appdirectory[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    					for index, filename in appdirectory do
    						success = File.Install(replacement, filename, FILE_INSTALL_ALWAYS, false, false, nil, nil );
    							error = Application.GetLastError();
    					if success == false then
        				Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    end
    					end
    				end
    			end
    		end
    Thanks for all the help by the way. I sure hope we get this figured out.

  8. #8
    Join Date
    Nov 2005
    Posts
    12
    Anyone else have any ideas on what I can do to make this work?
    Thanks

  9. #9
    Join Date
    Jan 2002
    Location
    Nashville TN
    Posts
    328
    If I under stand your post you find your files now you want to replace it with a file in your setup. In the install path for this file I would set a special "session variable" then when I find the file in PRE install, I simply use "String.SplitPath" and to set the session variable to that location, just make sure you select a good over right option, aka set it to always over right if that’s what you are needing. Good Luck

    path_Table = String.SplitPath(FOUNDFILE)
    SessionVar.Set("%INSTALLMYFILE%", path_Table.Drive..path_Table.Folder)
    Last edited by Jason Pate; 03-24-2006 at 12:22 PM.

  10. #10
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524

    Just a theory...

    Quote Originally Posted by mercury049
    I keep getting an error saying "Invalid Source" What am I missing?
    hmmmm... Invalid Source generally means that the source file does not exist.... maybe double check that the source path and filename exactly match the place your installer is putting the executable.

    Here's another thought... check the properties of actual file you are updating to... the code we have written is designed to find every instance of your .exe on the fixed drives and replace them with............. the one you just placed on the fixed drive........ lol. I wonder if the error you are getting is coming from the installer trying to replace a file with itself?
    Yeah right. Who's the only one here who knows the illegal ninja moves from the government?

    ()))))))))o)))))))==============================================

  11. #11
    Join Date
    Nov 2005
    Posts
    12
    That's a thought. But to rule that out I set it to blah2.exe instead of just blah.exe So it's replacing blah.exe with blah2.exe . Just for testing. But you make a fine point. When I actually run this, how'm I gonna get this to work. The post from Jason Pate seems like a good idea. I'm going to try it here in a bit and I'll post later tonight to let you all know how it goes.
    See, the thing is, in the end I just want it to take the files in the archive and overwrite or add to the directory's they belong in. The only problem is I need to find out where the user installed the software to begin with. I'm now wishing I would've had that stored in the registry, but it's too late now. Any other ideas?

    Jeff

  12. #12
    Join Date
    Jan 2002
    Location
    Nashville TN
    Posts
    328
    Yes I have done that before, and used my Idea and it works fine your just dynamically setting the appfolder during install time, if you have problem with it, let me know you can usually reach me online with MSN ID in my profile, or you can drop me an email. Good Luck. I can almost see the code if I close my eyes

  13. #13
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    mercury, I think the code you have is finding the target files just fine. It seems that the issue is with finding the source file.

    Is this the format you are using to declare the source file location?

    Code:
    replacement = "C:\BlahUpdater\blah2.exe";drivetbl = Drive.Enumerate();
    for drvindex, drives in drivetbl do
    		drive_type = Drive.GetType(drives);
    		if (drive_type == 3) then
    			appdirectory = File.Find(drives,"blah.exe",true,false,nil,nil);
    			if (appdirectory ~= nil)  then 
    				result = Dialog.Message("Notice", "" .. appdirectory[1], MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    					for index, filename in appdirectory do
    						success = File.Install(replacement, filename, FILE_INSTALL_ALWAYS, false, false, nil, nil );
    							error = Application.GetLastError();
    					if success == false then
        				Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
    end
    					end
    				end
    			end
    		end
    If so, try this instead:

    Code:
    replacement = "C:\\BlahUpdater\\blah2.exe";
    I'm now wishing I would've had that stored in the registry
    PS Don't forget to write that to the registry this time around.
    Yeah right. Who's the only one here who knows the illegal ninja moves from the government?

    ()))))))))o)))))))==============================================

Similar Threads

  1. Searching for a file and overwrite it with docs file
    By Wonderboy in forum AutoPlay Media Studio 6.0
    Replies: 32
    Last Post: 03-23-2006, 06:59 AM
  2. New Setup Factory 7.0 (v 7.0.2.0) Available
    By Darryl in forum Setup Factory 7.0
    Replies: 9
    Last Post: 03-06-2005, 01:57 PM
  3. AutoPlay Media Studio 4.0.0.3 Released
    By Brett in forum AutoPlay Media Studio 4.0
    Replies: 0
    Last Post: 12-11-2002, 08:39 AM
  4. Replies: 0
    Last Post: 08-17-2000, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts