Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


Sample Code to Change Ownership on Files

Keywords: 	 change ownership on files

;Program to change ownership on files
;Command line parameters specify starting folder, new owner, include subdirectories, URL of network server
;

AddExtender("WWWNT32I.DLL")
AddExtender("wsrch32i.dll")
xcount=0
flag=8 ;includes hidden files in the search

;make sure there are at least 2 command line parameters, and not more than 4
if param0<2 || param0>4
 Message("USAGE","Owner.exe   < S to include subdirectories> ")
 exit
endif
;param1 contains starting folder, so make sure it exists
If !DirExist(param1)then exit

;check if subdirectories are included
if param0>2
 if StrUpper(param3)=="S" then flag=24
endif

;check if network server specified
if param0<4 then param4=""  ;not specified
 
;start=Askline("PATH","Please enter the starting folder","")
;owner=Askline("OWNER","Please enter the required owner for these files","")
handle=srchInit(param1,"*.*","","",flag)   
   while 1
      xfile=srchNext(handle)
      if xfile=="" then break
      xcount=xcount+1
      ;ErrorMode(@OFF)
      ;owner = wntOwnerGet("", 0, xfile, 300, 0)
      ;ErrorMode(@ON)
      ;Message("%XFILE% Owner is", owner)
		wntOwnerSet(param4, 0, xfile, 300, param2)
   endwhile
srchFree(handle)

exit
;Display(2,"STATUS","FINISHED!")


Article ID:   W14952