7

I am trying to make my Windows System as compatible with existing Makefiles as possible. One great step that is missing is replacing the windows "find" (which is the same as grep) with the GNU find (list of all files in directory and sub directories). Is this possible? (I already have msys find installed and ready to go. Just removing system32/find.exe would probably work, but unfortunately it is not possible that easily)

Braiam
  • 4,709
  • 3
  • 26
  • 57
th3falc0n
  • 298
  • 3
  • 14
  • I rename my gnu utils find.exe to ufind.exe and use ufind – user619818 Aug 10 '14 at 12:03
  • The problem with that is, that this solution would result in different Makefiles across building platforms (as long as I didn't wish to create a ufind link on my Linux machines) – th3falc0n Aug 10 '14 at 12:06
  • 10
    Don’t do this. It _will_ break stuff. Instead, use a GNU environment like [Cygwin](http://cygwin.com/) or [MinGW](http://www.mingw.org/). – Daniel B Aug 10 '14 at 12:42
  • Well if I use the shell provided with msys in MinGW (which I am using) it is still dependent on Windows PATH variable which defines system32 and SysWOW64 as search paths and thus overrides the msys find. – th3falc0n Aug 10 '14 at 12:47
  • Something went wrong when installing then. %PATH% directories are search from front to back and the first match is used. As long as MinGW has its directories further to the front, everything is fine. – Daniel B Aug 10 '14 at 12:51
  • 1
    If you use `bash.exe` or `sh.exe` then using `find` will invoke the GNU find instead of the Win32 find. `sh.exe` and `bash.exe` come with `git` or MinGW. – Rapptz Aug 10 '14 at 17:18
  • It will only do so, if it is started with the proper script provided with msys in MinGW, because by default the msys binaries aren't added to the global Path variable by MinGW – th3falc0n Aug 11 '14 at 09:45

2 Answers2

16

Rather than removing Windows' find.exe, I strongly recommend putting GNU in your path before Windows\System32. For example, with Cygwin, you can use something like:

path c:\cygwin\bin;c:\windows\system32;c:\windows;c:\program files\foo;c:\program files\bar;c:\windows\system32\wbem

salehigal
  • 361
  • 1
  • 3
  • No need to do this manually, of course—it’s simply how this stuff works. From MSYS’ `/etc/profile`: `export PATH=".:/usr/local/bin:/bin:/mingw/bin:$PATH"` – Daniel B Aug 10 '14 at 13:19
  • 1
    If you go this route, it's better to limit the scope as much as possible. Don't change `PATH` for the entire system; change it only for the application you use (e.g. have a special batch file to launch a prompt with `set PATH=\path\to\cygwin;%PATH%`). This limits potential surprises later when you or someone else expects a Windows utility and instead gets a *nix one. – Bob Aug 10 '14 at 14:56
1

You can gain access to all protected files by changing the ownership.

For Windows 7, on the file or folder that you want to edit:

  • Go to Properties->Security->Advanced->Owner
  • Change owner to either Administrators or your own User
  • On Properties->Security grant rights to the new owner

Source: Windows 7 – How to Delete Files Protected by TrustedInstaller

Linger
  • 3,274
  • 10
  • 35
  • 47
th3falc0n
  • 298
  • 3
  • 14
  • 2
    Please include necessary steps in your answer. If the link dies at some time your answer will become much less useful. – gronostaj Aug 10 '14 at 12:27
  • And then any Windows Update (be it a bug fix, security fix, Service Pack or otherwise) could replace find.exe with the "correct" version again. This is a "global" solution to a "local" problem and they're invariably always a bad idea.. – Rob Aug 10 '14 at 15:09
  • 2
    You guess why I marked salehigal's answer as correct?, Mine is the solution to the problem I asked for, salehigal's solution is for the problem I actually had. – th3falc0n Aug 10 '14 at 15:29