Jump to content

Create your own system files?


spacesurfer

Recommended Posts

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


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.sys

The only problem is that your scripts will fail if they can't find the file.

Link to comment
Share on other sites

@Bezalel

Yes!! That works. It does find the file.

I used the command:

set tagfile=progs.sys
for %%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

Is it possible to nest the for statements?

set tags=programs documents music videos
for %%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 by Bezalel
Link to comment
Share on other sites

Please don't do it!

Nested FOR loops is bad practice, and can cause problems.

Try something like this instead

@echo off
for %%? in (programs documents music videos) do call :setit %%?
goto :eof
:setit
for /f "delims=\" %%? in ('mountvol^|find ":\"') do dir/b/as-d %%?\%1.sys &&label %%? %1
goto :eof

Edited by Yzöwl
Link to comment
Share on other sites

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

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 by spacesurfer
Link to comment
Share on other sites

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

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 %%? %1

to

&&set %1=%%?

</Edit>

Edited by Yzöwl
Link to comment
Share on other sites

@yzowl

I'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
:setit
for /f "delims=\" %%? in ('mountvol^|find ":\"') do dir/b/as-d %%?\%1.hdd &&set %1=%%?
echo %programs%
echo %media%
pause
goto :eof

:eof
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%programs%" /ve /d "%windir%\Resources\Icons\progs_drive.ico" /f

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\%documents%" /ve /d "%windir%\Resources\Icons\docs_drive.ico" /f

My 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 by spacesurfer
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...