spacesurfer Posted June 28, 2006 Share Posted June 28, 2006 How do you create your own system file - a file that cannot be viewed even when "Show hidden files" is enabled.Here is what want to do.In my Media partition (H:), I want to put a file called media.sys (0 bytes). I want to hide media.sys so it can't be seen and can't be deleted and is not a nuisance.Then, I want to be able to search for this file like you search for the tagfile during windows setup and assign the drive where it belong to a variable.Then, I can label that partition "Media".I want to be able to do this to all my partitions during setup... for example, find my Documents partition and label it "Documents", Images partition and label it "Images", Programs partition and label it "Programs" automatically by using these 0-byte system files.Of course, I can make these files hidden and make it work, but I wanted these files hidden even when hidden files are enabled. Link to comment Share on other sites More sharing options...
Bezalel Posted June 29, 2006 Share Posted June 29, 2006 How do you create your own system file - a file that cannot be viewed even when "Show hidden files" is enabled.Here is what want to do.In my Media partition (H:), I want to put a file called media.sys (0 bytes). I want to hide media.sys so it can't be seen and can't be deleted and is not a nuisance.Then, I want to be able to search for this file like you search for the tagfile during windows setup and assign the drive where it belong to a variable.Then, I can label that partition "Media".I want to be able to do this to all my partitions during setup... for example, find my Documents partition and label it "Documents", Images partition and label it "Images", Programs partition and label it "Programs" automatically by using these 0-byte system files.Of course, I can make these files hidden and make it work, but I wanted these files hidden even when hidden files are enabled.ATTRIB +S +H +R h:\media.sysThe only problem is that your scripts will fail if they can't find the file. Link to comment Share on other sites More sharing options...
spacesurfer Posted June 29, 2006 Author Share Posted June 29, 2006 @BezalelYes!! That works. It does find the file.I used the command:set tagfile=progs.sysfor %%i in (c d e f g h i j k l m n o p q r s t u v w x y z) do if exist "%%i:%tagfile%" set PROGS=%%i:to find my Programs partition.I can store my programs locally rather than CD to automatically install on first run.This is useful for silent install of Office - it would run faster off hard drive than from CD.Thanks again. Link to comment Share on other sites More sharing options...
Bezalel Posted June 29, 2006 Share Posted June 29, 2006 (edited) Is it possible to nest the for statements?set tags=programs documents music videosfor %%I in (%tags%) do for %%J in (c d e f g h i j k l m n o p q r s t u v w x y z) do if exist "%%J:%%I.sys" set %%I=%%J:Update: I tested this code and it works. Edited June 29, 2006 by Bezalel Link to comment Share on other sites More sharing options...
spacesurfer Posted June 29, 2006 Author Share Posted June 29, 2006 thanks for nested script. I'll try it when i get home.i'll also have to try to create permanent variables for these drives so it works throughout. Link to comment Share on other sites More sharing options...
Yzöwl Posted June 29, 2006 Share Posted June 29, 2006 (edited) Please don't do it!Nested FOR loops is bad practice, and can cause problems.Try something like this instead@echo offfor %%? in (programs documents music videos) do call :setit %%?goto :eof:setitfor /f "delims=\" %%? in ('mountvol^|find ":\"') do dir/b/as-d %%?\%1.sys &&label %%? %1goto :eof Edited June 29, 2006 by Yzöwl Link to comment Share on other sites More sharing options...
Sonic Posted June 29, 2006 Share Posted June 29, 2006 Note the hidden is viewable if you enable "Display systems files"^^ Yzöwl you're crazy with your complex script but they always works Link to comment Share on other sites More sharing options...
spacesurfer Posted June 29, 2006 Author Share Posted June 29, 2006 that is exactly what i want - visible when display system files is enable but invisible when show hidden files is enabled.that way, the file is not annoying when i open those drives. Link to comment Share on other sites More sharing options...
Yzöwl Posted June 29, 2006 Share Posted June 29, 2006 The 'complex' version will only check your drives, not ones you don't have.The original, nested command will actually check four permutations of twenty four drives, i.e it will look 96 times for its files. If you only have C: D: E: F: drives it will still look for those four files in G: H: I: J:Z:. Link to comment Share on other sites More sharing options...
spacesurfer Posted June 29, 2006 Author Share Posted June 29, 2006 (edited) what exactly does your complex script do before i use it? i can't tell from your script what it does.what i want is to search for the file (i.e. h:\progs.sys, g:\media.sys, i:\music.sys) and assign the drive letter to the varialbe (i.e. %progs%=g:, %media%=g, %music%=i:is this what the script does?(forget about labeling the drive part as i mention in original post. that was kind of dumb since once the drive is labeled, the label does not reset itself after reinstallation of windows.) Edited June 29, 2006 by spacesurfer Link to comment Share on other sites More sharing options...
Sonic Posted June 29, 2006 Share Posted June 29, 2006 Simplified explication ...for %%? in (programs documents music videos) do call :setit %%?For each "items" it will execute 'setit' function with argument 'item' (the first will be programs). After function finish the work, it will rexecute the function but with the second item (documents) as argument and etc.goto :eof After finish go to end of file, so it exist in fact ...:setit The 'function' name ... do nothing ... it's called by the first command ...for /f "delims=\" %%? in ('mountvol^|find ":\"') do dir/b/as-d %%?\%1.sys &&label %%? %1 The command mountvol display information about volumes. We keep only the letters with 'for' and assign letter to a variable (%%? different from the first %%?).Next we list %%? (so the first letter found) and the 'item' given as agrument, if no file found, nothing is done and continue and if no code error (file is present) (&& operator detect error or not) we will set the drive with 'label' command %%? (letter) %1 (the first item). The 'for' command will rerun with the second letter and etc. If nothing to do then exit and the first command is reexecuted with second 'item' documents and this function will redo the work ...I hope you understand me, sorry I'm french, and the method is basic but to explain easily it's harder ...Goodbye. Link to comment Share on other sites More sharing options...
Yzöwl Posted June 29, 2006 Share Posted June 29, 2006 (edited) It searches the root of each drive on your system for a system file named either programs.sys, documents.sys, music.sys or videos.sys. If found it will label that volume with that filename, (minus the extension).<Edit>Since you.ve now changed your mind on the volume labels you may wish to change&&label %%? %1to&&set %1=%%?</Edit> Edited June 29, 2006 by Yzöwl Link to comment Share on other sites More sharing options...
spacesurfer Posted June 30, 2006 Author Share Posted June 30, 2006 (edited) @yzowlI'm trying to add registry keys that change the drive icons with your method. Here is what I have but it doesn't work:for %%? in (programs documents media ghost satsang) do call :setit %%?goto :eof:setitfor /f "delims=\" %%? in ('mountvol^|find ":\"') do dir/b/as-d %%?\%1.hdd &&set %1=%%?echo %programs%echo %media%pausegoto :eof:eofreg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%programs%" /ve /d "%windir%\Resources\Icons\progs_drive.ico" /freg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%documents%" /ve /d "%windir%\Resources\Icons\docs_drive.ico" /fMy question is, does the reg add run after the loop is complete?What about the %programs% variable - is it H: or is it H? If it has a colon after it, I don't think it would work. How do you remove colon?Also, how do you run reg add command outside the loop and not within the loop? Edited June 30, 2006 by spacesurfer 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