how to protect files -


i using bat file protect files. requires user key in password make folder visible.

but in c# program want open file seems can't find file when hidden bat file (if (file.exists(ls_path)) returns false).

is related bat file?

i tested in normal hide @ window program still able read out path.

cls @echo off title folder locker if exist "control panel.{21ec2020-3aea-1069-a2dd-08002b30309d}" goto unlock if not exist locker goto mdlocker :confirm echo sure u want lock folder(y/n) set/p "cho=>" if %cho%==y goto lock if %cho%==y goto lock if %cho%==n goto end if %cho%==n goto end echo invalid choice. goto confirm :lock ren locker "control panel.{21ec2020-3aea-1069-a2dd-08002b30309d}" attrib +h +s "control panel.{21ec2020-3aea-1069-a2dd-08002b30309d}" echo folder locked goto end :unlock echo enter password unlock folder set/p "pass=>" if not %pass%==123 goto fail attrib -h -s "control panel.{21ec2020-3aea-1069-a2dd-08002b30309d}" ren "control panel.{21ec2020-3aea-1069-a2dd-08002b30309d}" locker echo folder unlocked goto end :fail echo invalid password goto end :mdlocker md locker echo locker created goto end :end 

with vbscript, rather check see if file exists, try open , use error trap. i'm not familiar batch, suspect can use similar technique.

instead of:

    if objfso.fileexists(somefilevariable) _ set objtestfile = objfso.opentextfile(somefilevariable, forreading, true, tristatefalse) 

you have:

on error resume next set objtestfile = objfso.opentextfile(somefilevariable, forreading, true, tristatefalse) if err.number= 0     ' opened ok, stuff else     ' failed, else end if 

Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -