VBscript to delete games

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viper888
    New Member
    • Sep 2007
    • 5

    VBscript to delete games

    Kindly check this VBscript that i used in Win2000 server, It doesn't seem to work. What seems to be the problem? Can you help me?
    [CODE=vb]
    dim strExcludedPC

    ServerFileSave= "\\S06-admin-06\User Area\Save\"
    strComputer = "."
    ctr=0

    arExcludedPCs=A rray("PC1", "PC2")
    Set objNetwork = Wscript.CreateO bject("Wscript. Network")
    objComputerName = objNetwork.Comp uterName

    '===Check for computers that are excluded, then quit script===
    for Each strExcludedPC in arExcludedPCs
    if objComputerName =strExcludedPC then
    wscript.quit
    end if
    Next

    Set objWMIService = GetObject("winm gmts:" _
    & "{impersonation Level=impersona te}!\\" & strComputer & "\root\cimv 2")

    Set colFiles = objWMIService.E xecQuery _
    ("SELECT * FROM CIM_DataFile WHERE " _
    & "FileName='boun ce' AND Extension='exe' OR " _
    & "FileName='avse q1' AND Extension='dat' OR " _
    & "FileName='zagu ' AND Extension='exe' OR " _
    & "FileName='zagu 1' AND Extension='exe' OR " _
    & "FileName='zagu 2' AND Extension='exe' OR " _
    & "FileName='zagu 3' AND Extension='exe' OR " _
    & "FileName='MCFH untsville' AND Extension='exe' OR " _
    & "FileName='pica chu' AND Extension='exe' OR " _
    & "FileName='figh t9' AND Extension='exe' OR " _
    & "FileName='unfo lding' AND Extension='exe' OR " _
    & "FileName='wack ywordsearch' AND Extension='exe' OR " _
    & "FileName='sudo ku' AND Extension='exe' OR " _
    & "FileName='grid lock' AND Extension='exe' OR " _
    & "FileName='cube delic' AND Extension='exe' OR " _
    & "FileName='magn etism' AND Extension='exe' OR " _
    & "FileName='plum ber' AND Extension='exe' OR " _
    & "FileName='simo n' AND Extension='exe' OR " _
    & "FileName='plum ber2' AND Extension='exe' OR " _
    & "FileName='mill ionaire' AND Extension='exe' OR " _
    & "FileName='xray e' AND Extension='exe' OR " _
    & "FileName='Flas h Games' AND Extension='exe' OR " _
    & "FileName='acad ' AND Extension='exe' OR " _
    & "FileName=' bou' AND Extension='exe' OR " _
    & "FileName='scra bout' AND Extension='exe' OR " _
    & "FileName=' ttw' AND Extension='exe' OR " _
    & "FileName='text twist' AND Extension='exe' OR " _
    & "FileName='hang aroo' AND Extension='exe' OR " _
    & "FileName='hang man' AND Extension='exe' OR " _
    & "FileName='same ' AND Extension='exe' OR " _
    & "FileName='zuma ' AND Extension='exe' OR " _
    & "FileName=' zuma deluxe' AND Extension='exe' OR " _
    & "FileName=' zuma deluxe' AND Extension='zip' OR " _
    & "FileName='book worm' AND Extension='exe' OR " _
    & "FileName='Book wormAdventures' AND Extension='exe' OR " _
    & "FileName='Book Worm Adventures Deluxe From GameHouse By TFT-TEAM' AND Extension='exe' OR " _
    & "FileName='pyra mid' AND Extension='exe' OR " _
    & "FileName='dyno mite' AND Extension='exe' OR " _
    & "FileName='rive riqgame' AND Extension='exe' OR " _
    & "FileName=' ra2' AND Extension='exe' OR " _
    & "FileName='game ' AND Extension='exe' OR " _
    & "FileName='coll apse' AND Extension='exe' OR " _
    & "FileName='arca noid' AND Extension='exe' OR " _
    & "FileName='ptan ks' AND Extension='exe' OR " _
    & "FileName='feed ingfrenzy' AND Extension='exe' OR " _
    & "FileName='feed ingfrenzy' AND Extension='zip' OR " _
    & "FileName='scra bble' AND Extension='exe' OR " _
    & "FileName='pool ' AND Extension='exe' OR " _
    & "FileName='bloc ks' AND Extension='exe' OR " _
    & "FileName='allo ut' AND Extension='exe' OR " _
    & "FileName='wina mp' AND Extension='exe' OR " _
    & "FileName='mily onaryo' AND Extension='exe' OR " _
    & "FileName='tumb lebugs' AND Extension='exe' OR " _
    & "FileName=' bob' AND Extension='exe' OR " _
    & "FileName=' bob' AND Extension='rwg' OR " _
    & "FileName='Myst eryCaseFiles' AND Extension='rwg' OR " _
    & "FileName='Prim eSuspects' AND Extension='rwg' OR " _
    & "Extension='mp3 ' OR Extension='mp4' or Extension='mpeg ' OR Extension='wma' ")


    '===Check if files found===
    For Each objFile in colFiles
    ctr=ctr+1
    Next

    '===Quit if no files found===
    if ctr=0 then
    WScript.Quit
    end if

    '===else write the text file=========== =============== =============== =============== ==========> games found
    objUserName = objNetwork.User Name
    mySaveFile="C:\ " & objComputerName & ".txt"

    Set fs = CreateObject("S cripting.FileSy stemObject")

    '===if server save folder does not exist, quit program===
    if NOT fs.FolderExists (ServerFileSave ) then
    '====== msgbox "folder does not exist"
    WScript.Quit
    end if

    '===else determine if for appending or new create===
    if fs.FileExists(S erverFileSave & objComputerName & ".txt") then
    Set myScriptFile = fs.OpenTextFile (mySaveFile, 8, True)
    else
    Set myScriptFile = fs.CreateTextFi le(mySaveFile, True)
    end if

    myScriptFile.Wr iteLine("-----------------------------------------------------------")
    myScriptFile.Wr iteLine("The Network Administrator")
    myScriptFile.Wr iteLine("Games and music files found at " & objComputerName & "@" & objUserName)
    myScriptFile.Wr iteLine("Date: " & date() & " Time: " & Time())
    myScriptFile.Wr iteLine("====== =============== =============== =============== ========")
    myScriptFile.Wr iteLine("NOTE: The following files are prohibited from our network")
    myScriptFile.Wr iteLine(" and will be deleted automatically:" )
    myScriptFile.Wr iteLine("")


    '===Delete the files found===
    For Each objFile in colFiles
    objFile.Delete
    myScriptFile.Wr iteLine(objFile .Name)
    ctr=ctr+1
    Next

    myScriptFile.Wr iteLine("")
    myScriptFile.Cl ose

    '===Copy listing file to server===
    fs.CopyFile mySaveFile, ServerFileSave
    'fs.DeleteFile mySaveFile (do not delete save files)

    '===if games found, open txt file as warning to the user===
    Set WshShell = WScript.CreateO bject("WScript. Shell")
    WshShell.Run mySaveFile


    ' & "FileName=' sol' AND Extension='lnk' OR " _
    ' & "FileName='free cell' AND Extension='lnk' OR " _
    ' & "FileName='winm ine' AND Extension='lnk' OR " _
    ' & "FileName='mshe art' AND Extension='lnk' OR " _
    ' & "FileName='pinb all' AND Extension='lnk' OR " _




    ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''
    Function CheckTrend()

    ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''
    strComputer = "."
    Set objWMIService = GetObject("winm gmts:{impersona tionLevel=imper sonate}!\\" & strComputer & "\root\cimv 2")

    Set colFiles2 = objWMIService.E xecQuery("SELEC T * FROM CIM_DataFile WHERE FileName='lpt$v pn'")

    '===Check if files found===
    For Each objFile in colFiles2
    ctr=ctr+1
    Next

    '===Quit if no files found===
    if ctr=0 then
    myScriptFile.Wr iteLine("No TrendMicro virus pattern found!!!")
    end if

    Dim fso, f
    Set fso = CreateObject("S cripting.FileSy stemObject")

    '===Write files found===
    For Each objFile in colFiles2
    myScriptFile.Wr iteLine(objFile .Name)
    Set f = fso.GetFile(obj File.Name)
    myScriptFile.Wr iteLine(" date created: " & f.DateCreated)
    myScriptFile.Wr iteLine("")
    ctr=ctr+1
    Next

    End Function[/CODE]
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    For software development, you'll want to post in the Visual Basic Forum, and please use [CODE] tags, as described in out Posting Guidelines. Thank you.

    Comment

    • Cyberdyne
      Recognized Expert Contributor
      • Sep 2006
      • 627

      #3
      Originally posted by bartonc
      For software development, you'll want to post in the Visual Basic Forum, and please use [CODE] tags, as described in out Posting Guidelines. Thank you.
      imagine if somebody sends this in an e-mail attachment and the person on the other side executes it.

      Cyber

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Originally posted by Cyberdyne
        imagine if somebody sends this in an e-mail attachment and the person on the other side executes it.

        Cyber
        Huh??? My post or viper888's? I don't get it either way.

        Comment

        • epots9
          Recognized Expert Top Contributor
          • May 2007
          • 1352

          #5
          Originally posted by Cyberdyne
          imagine if somebody sends this in an e-mail attachment and the person on the other side executes it.

          Cyber
          It'll clean out the computer of any files that are media related and game exe's...but its just deleting the exe but the registry keys still are there and that can cause problems.

          Comment

          Working...