WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sample code
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

KidProof.wbt Provides Parental Control Over Desktop

Keywords: security

Here's a sample script to load programs, and then hide other stuff on the desktop. Also uses added security, such as password entry.

 a1="Lets you load some programs that kids want to play with, and then by "
 a2="running this script, it will hide ProgMan and any iconized programs. "
 a3="When all initial windows have been closed, you will be prompted for a "
 a4="password to continue.  When the correct password is entered, the "
 a5="iconized windows will come back.  PS.  The password for now is TINCAN"

 a6=StrCat(a1,a2,a3,a4,a5)
 Message("KidProof",a6)
 Drop(a1,a2,a3,a4,a5,a6)

 ;<-----------------------snip-------------------------------------------->

 ;Are we already running?
 If WinState("Program Manager")==@HIDDEN
    Display(5,"Hmmm","KidProof already running")
    Exit
 EndIf

 PswdMsg="Password is tincan"   ; !!!!!!!!!!!!!!Edit this line
 Password="tincan"              ; !!!!!!!!!!!!!!Edit this line too

 ;Stay Running!!!   This function required batch file to have normal exit
 IntControl(12,10,"Close all programs before shutting down Windows",0,0)

 ; Now we get busy
 ;Get currently installed taskmanager
 ;debug(1)
 OrigTask=IniReadPvt("boot","taskman.exe","taskman.exe","system.ini")
 OrigTask=FileLocate(OrigTask)

 If OrigTask==""          ; Initiate disaster recovery (Kid pressed reset button, etc)
    Display(3,"Disaster Recovery","In Progress")
    OrigTask=IniReadPvt("KIDTOY","Origtm",StrCat(DirWindows(0),"taskman.exe"),"WWW-PROD.INI" )
    CopyTask2=IniReadPvt("KIDTOY","backuptm",StrCat(DirWindows(0),"taskman.cp2"),"WWW-PROD.INI" )
    If !FileExist(CopyTask2)
       Message("Disaster Recovery","Task Manager missing.  Best Wishes")
       Exit
    EndIf
    FileCopy(CopyTask2,OrigTask,0)
    Display(3,"Disaster Recovery","Complete")
 EndIf

 ppp=FilePath(OrigTask)              ; Parse out file names
 rrr=FileRoot(OrigTask)
 eee=FileExtension(OrigTask)
 CopyTask=StrCat(ppp,rrr,".CPY")     ; Build working file name
 CopyTask2=StrCat(ppp,rrr,".CP2")    ; Build disaster recovery file name

 If !FileExist(CopyTask2)             ; Save info for future disasters
      FileCopy(OrigTask,CopyTask2,0)  ; Permanent backup   for future disaster recovery
      IniWritePvt("KIDTOY","Origtm",OrigTask,"WWW-PROD.INI")
      IniWritePvt("KIDTOY","backuptm",CopyTask2,"WWW-PROD.INI")
 EndIf

 ; Remove task manager
 If FileExist(OrigTask)
    FileMove(OrigTask,CopyTask,0)
 EndIf



 ;Following code helps in debug
 ;ErrorMode(@off)
 ;WinTitle("Program Manager","")
 ;ErrorMode(@cancel)
 ;Iconize Progman and File manager (comment out for debug )
 ErrorMode(@OFF)
 WinIconize("Program Manager")
 WinIconize("File manager")
 ErrorMode(@CANCEL)

 ;Grab current Windows and hide iconized ones.
 GoSub SetupSplash

 While @TRUE
     Delay(2)               ; Don't suck up all system resources continiously
     a=WinGetactive()       ; Any active Windows ???
     If a == "" Then Break  ; No?  We are done
 EndWhile

 :CANCEL
 While @TRUE
    ; Get authorization
    pswd=AskPassword(PswdMsg,"Enter Password")
    password=StrLower(password)
    pswd=StrLower(pswd)
    If pswd==password Then Break
    Display(5,"Ooopsie","Bad Password")
 EndWhile

 ;Bring back Windows
 GoSub UnSplash

 ;Restore Taskmanager
 ;debug(1)
 FileMove(CopyTask,OrigTask,0)



 Exit


 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;SetupSplash hides all iconic windows, remembers winstate
 :setupsplash
 OrigWindowList=WinItemize()   ;Get list of all open Windows
 OrigWindowCount=ItemCount(OrigWindowList,@TAB)
 For i=1 To OrigWindowCount
    a=ItemExtract(i,OrigWindowList,@TAB)
    b = WinState(a)
    OrigWindowState%i% = b
    ; Note we could hide the other windows here, but if the install
    ; bombs kind of bad, it leaves the user in a lurch and they
    ; got to reboot.  Bad news.    With icons they can always recover
    ; by themselves.
    If b==@ICON Then WinHide(a)
 Next

 Return
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;UnSplash undoes Setup Splash
 :UnSplash
 ErrorMode(@OFF)
 For i= OrigWindowCount To 1 By -1
    a=ItemExtract(i,OrigWindowList,@TAB)
    ;Display(3,"Window",a)
     Switch OrigWindowState%i%
   Case @HIDDEN
      Break
   Case @NORMAL
      WinShow(a)
      Break
   Case @ICON
      WinShow(a)
      Break
   Case @ZOOMED
      WinZoom(a)
      Break
     End Switch
 Next
 ErrorMode(@CANCEL)
 return;


Article ID:   W13752
Filename:   KidProofwbt Provides Parental Control Over Desktop.txt
File Created: 2006:09:22:10:50:16
Last Updated: 2006:09:22:10:50:16