Code: |
@echo off dir %1\*.exe /a-D /b /S >>test.log if errorlevel 0 echo exe found if errorlevel 1 echo exe not found |
Code: |
@echo off dir %1\*.exe /a-D /b /S >>test.log if errorlevel 1 goto exit echo do stuff :exit echo done! |
TheKingster wrote: |
if your trying to stop people running EXEs theres a whole section on that on these forums |
Code: |
@echo off echo checking userarea for inappropriate files dir %1\*.exe /a-D /b /S >>%1\test.log dir %1\*.mp3 /a-D /b /s >>%1\test.log if errorlevel 1 goto exit echo mailing filelist to administrator! \\lsahtc_nt1\netlogon\blat %1\test.log -to andy@address -server 192.168.0.15 -f academic\%username% -q :exit del %1\test.log echo done! |
Code: |
'on error resume next Const ForReading = 1 wscript.echo ("checking your user area for inappropriate files") set wshell = wscript.createobject("wscript.shell") Dim fso, f1, ts, s,myfile,uname,udate Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists("s:\ftemp.$$$")) Then fso.DeleteFile("s:\ftemp.$$$") end if uname = wshell.ExpandEnvironmentStrings("%USERNAME%") if instr("sbutte,adavis,jowen,naparro,vballa,cglen-,rbanni,jfairc,andy,myles,duncan,brian,ssstoke,abaill,adavis,msimps", uname) OR isempty(uname) then wscript.exit WShell.Run "%comspec% /c dir s:\*.exe /a-d /b /s >> s:\ftemp.$$$",0,true WShell.Run "%comspec% /c dir s:\*.mp3 /a-d /b /s >> s:\ftemp.$$$",0,true WShell.Run "%comspec% /c dir s:\*.wav /a-d /b /s >> s:\ftemp.$$$",0,true 'read file Set f = fso.GetFile("s:\ftemp.$$$") if f.size > 0 then wscript.echo ("mailing file list to administrator") wshell.run "\\lsahtc_nt1\netlogon\blat s:\ftemp.$$$ -to andy@lythamhigh.lancs.sch.uk -server 192.168.0.15 -f academic\" & uname & " -q", 0,true wscript.echo ("mail sent!") datetemp = date udate = replace (datetemp,"/","") ttemp = time ttime = replace (ttemp,":","") folname = "\\lsahtc_nt1\logs\filez\" & uname & udate &"-"& ttime 'make folder set f = fso.createfolder(folname) 'move files Set MyFile = fso.Opentextfile("s:\ftemp.$$$", ForReading,false) do while myfile.AtEndOfStream <> True fpath = myfile.readline cmdline = "%comspec% /c move /y " & """" & fpath & """ " & folname wscript.echo "moving " & fpath WShell.Run cmdline, 0,true loop myfile.close else wscript.echo ("Clear!") end if fso.DeleteFile("s:\ftemp.$$$") set wshell = nothing set fso = nothing set f = nothing set myfile = nothing |
output generated using printer-friendly topic mod, All times are GMT + 2 Hours