On 30 Dec 2009 at 14:11, Matthew W. Ross wrote: > Yes, but I'm not very good at making scripts... At least not on Windows. > > Is there an equivalent to 'sed' for Windows? I need to delete that line, > then append the correct setting to the end of the file.
Clay's Utilities from http://clayruth.com/claysutl.html has XCHANG32.EXE which will handle this by replacing text, or YANK32 which will yank matching lines from a file (so you can append what you want). They're freeware and work well in batch files. You can't assume that Firefox will be in the same place, you need to get the location of all.js by reading the following keys: HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox CurrentVersion=3.5.6 (en-US) Useing the value of "CurrentVersion", get the path to the EXE: HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox\3.5.6 (en-US)\Main Install Directory=D:\Programs\Firefox Using the "Install Directory", get to "all.js": D:\Programs\Firefox\greprefs\all.js If you want to use XCHANG32 to change pref("network.proxy.type", 0); to pref("network.proxy.type", 4);, here's how I would do it: ------- Included Stuff Follows ------- XCHANG32.EXE 4.1 - Binary Edit by Clay Ruth - 32-bit Console Version 01/17/2005 XCHANG32 [/i][/s] fs "[srchstrng][^[x]chr,][...]" ["[replstrng][^[x]chr,][...]"] XCHANG32 [/i][/s] fs @scriptfil or XCHANG32 [/i][/s] fs "srchspec" @imagefil Switch /i = ignore case; /s = simple strings (use ^ and , as-is); chr = ASCII. Search and replace strings can be any combination of literals and ^-prefixed, comma-delimited ASCII codes (^0 through ^255 or ^x00 through ^xFF). Double-up a literal ^ or , (or use /s). Quotes may be omitted if there are no spaces within strings. Script file has quoted search and replace string specs on one line; script or image file 65,534 chars max; search string 4,095 chars max. ZIP file embedded path change must include highest embedded directory level, and each altered ZIP file must be fixed with PKWare's PKZIPFIX before use. For ZIP modification to work, the first zipped file must have the sought path. Echos "Changed" or "Not Changed" to visually indicate outcome. Returns errorlevel: 0 = changed, 1 = not changed, 2 = unable to rewrite/del, 3 = syntax or memory error, 4 = file not found, 5 = error during read/write, 6 = insufficient disk space, 7 = read-only file, 8 = write-protected. When wildcards are used, highest level for the file group is returned. --------- Included Stuff Ends --------- Repeat this line while it returns errorlevel 0 ("changed), until it returns errorlevel 1 and there are no more double-spaces following the comma after "network.proxy.type": XCHANG32 /i all.js "pref(^34,network.proxy.type^34,, " "pref(^34,network.proxy.type^34,, " then execute the following line to change the 0) to 4), but only on the line containing "network.proxy.type": XCHANG32 /i all.js "pref(^34,network.proxy.type^34,, 0)" "pref(^34,network.proxy.type^34,, 4)" HTH Angus -- Angus Scott-Fleming GeoApps, Tucson, Arizona 1-520-290-5038 +-----------------------------------+ ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~