Announcement

Collapse
No announcement yet.

run Symantec Cleanwipe with PsExec

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • run Symantec Cleanwipe with PsExec

    Hi All

    I'm hoping someone on here will be able to help as I have exhausted google and all other avenues. I am no expert when it comes to scripting but I'm hoping someone can tell me if the following can be scripted.

    I need to remove Symantec Antivirus 8 from about 400 pc's. I have managed to find scripts to help determine which machines have been left on (I have asked users but I know some people will still shutdown).

    So I have a text file with a list of pc names that I know are turned on and I have also copied across the CleanWipe folder which contains an app folder and a bat file.

    Now in the cleanwipe readme it says the following,

    To run CleanWipe in silent mode:
    --------------------------------
    1. Copy the CleanWipe folder to the target computer.
    2. Open the CleanWipe folder and double-click the CleanWipe.exe file.
    3. When you are prompted, browse to a location where you want the files to be copied and then click Start to extract the files.
    If you click Start without selecting a location, the files are extracted to the Windows\Temp folder.
    4. If you are asked if you want to run CleanWipe now, click No.
    5. Open a command prompt and change directory to the CleanWipe\app folder.
    6. Type the following command:
    RunCleanWipe -silent
    7. CleanWipe then uses its defaults to run without any user input.

    Okay, so I tested this with PsExec and did the following,

    psexec backslashbackslashpcname cmd (replace backslashbackslash with \\)

    which would take me to

    PsExec v1.98 - Execute processes remotely
    Copyright (C) 2001-2010 Mark Russinovich
    Sysinternals - www . sysinternals . com

    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\WINDOWS\system32>

    Now I will navitage to the folder where I meant to run RunCleanWipe -silent

    C:\CleanWipe\app\ and then I run RunCleanWipe -silent

    This works great and starts the first process of cleanwipe. I then have to log on to the specific machine to initiate the second process of cleanwipe. I haven't found a way to automate that but first things first I suppose

    I found the following script but this doesn't work (alive.txt is the list of pcs)

    for /f %a in (C:\ping\Alive.txt) do psexec backslashbackslash%a "c:\CleanWipe\app\RunCleanWipe -silent" (replace backslashbackslash with \\)

    but when I run this I get the following error

    PsExec could not start c:\CleanWipe\app\RunCleanWipe -silent on pcname:
    The system cannot find the file specified

    Can someone please explain why this is happening with the above command but when I do it manually it works?

    Your help with this will be much appreciated!
    p.s. because this is my first post I cannot post urls hence why I did (replace backslashbackslahs with \\)

  • #2
    Re: Script to run Symantec Cleanwipe with PsExec

    I'd just like to add that I have also run the command without the double quotes,

    for /f %a in (C:\ping\Alive.txt) do psexec \\%a c:\CleanWipe\app\RunCleanWipe -silent

    and get the same error.
    Last edited by Rems; 9th January 2011, 22:57.

    Comment


    • #3
      Re: Script to run Symantec Cleanwipe with PsExec

      1) Because of the double quotes in "c:\CleanWipe\app\RunCleanWipe -silent" => "RunCleanWipe -silent" is interpreted as the name of a file.

      2) Always use file extensions for the remote files.


      example:
      Code:
      for /f "usebackq" %%a in ("C:\ping\Alive.txt") do psexec.exe \\%%a "c:\CleanWipe\app\RunCleanWipe.exe" -silent
      
      :: (Use %a when entered on command prompt, 
      ::  use %%a when the for-do command is launched from batch file)
      or maybe,
      Code:
      psexec.exe \\@C:\ping\Alive.txt -d "c:\CleanWipe\app\RunCleanWipe.exe" -silent
      \Rems
      Last edited by Rems; 9th January 2011, 22:55.

      This posting is provided "AS IS" with no warranties, and confers no rights.

      __________________

      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts

      Comment


      • #4
        Re: Script to run Symantec Cleanwipe with PsExec

        Hi Rems

        Thank you for your reply

        I ran

        psexec.exe \\@C:\ping\Alive.txt -d "c:\CleanWipe\app\RunCleanWipe.bat" -silent

        and it seemed to work but none of the pc's rebooted. So I think it the -silent switch didn't work and perhaps it was waiting for some kind of user input.

        What is meant to happen is when you run c:\CleanWipe\app\RunCleanWipe -silent (this is a batch file by the way) from PsExec it reboots the pc once and then when I log in it runs a batch file called RunTwice.bat which lives in the C:\ drive.

        The first stage is getting the RunCleanWipe -silent to work thoug.

        Comment


        • #5
          Re: Script to run Symantec Cleanwipe with PsExec

          For testing use the -i switch of psexec when running against a test computer, to find out if it does show the "reboot dialog window".


          try also,
          Code:
          for /f "usebackq" %%a in ("C:\ping\Alive.txt") do psexec.exe \\%%a -d cmd.exe /c call "c:\CleanWipe\app\RunCleanWipe.bat" -silent

          \Rems

          This posting is provided "AS IS" with no warranties, and confers no rights.

          __________________

          ** Remember to give credit where credit's due **
          and leave Reputation Points for meaningful posts

          Comment


          • #6
            Re: Script to run Symantec Cleanwipe with PsExec

            Hi Rems

            I ran

            for /f "usebackq" %%a in ("C:\ping\Alive.txt") do psexec.exe \\%%a -d cmd.exe /c call "c:\CleanWipe\app\RunCleanWipe.bat" -silent

            but got an error

            %%a was unexpected at this time.

            I forgot to mention this is also the error I got when I ran

            for /f "usebackq" %%a in ("C:\ping\Alive.txt") do psexec.exe \\%%a "c:\CleanWipe\app\RunCleanWipe.bat" -silent

            which was the command line you gave me in your previous reply.
            Last edited by Rems; 10th January 2011, 16:19.

            Comment


            • #7
              Re: Script to run Symantec Cleanwipe with PsExec

              You need to use %%a only when the for-do command is launched from batch file.
              Use %a when entered on command prompt.

              \Rems

              This posting is provided "AS IS" with no warranties, and confers no rights.

              __________________

              ** Remember to give credit where credit's due **
              and leave Reputation Points for meaningful posts

              Comment


              • #8
                Re: Script to run Symantec Cleanwipe with PsExec

                Hi Rems

                I tried

                for /f "usebackq" %a in ("C:\ping\Alive.txt") do psexec.exe \\%a -d cmd.exe /c call "c:\CleanWipe\app\RunCleanWipe.bat" -silent

                and I get the following response

                cmd.exe started on pcname with process ID 3096.

                I tried

                psexec.exe \\@C:\ping\Alive.txt -d "c:\CleanWipe\app\RunCleanWipe.bat" -silent

                and get the following response

                \\pcname:

                c:\CleanWipe\app\RunCleanWipe.bat started on pcname with process ID 2420.


                What I don't understand is what is causing the problem. Is it PsExec that is letting this process fail or is it the RunCleanWipe.bat -silent that won't work from a command line/script?

                Many thanks in advance for your help.

                Comment


                • #9
                  Re: Script to run Symantec Cleanwipe with PsExec

                  Those results mean the process started successfully.

                  What you may have to do (and PLEASE test this in a test environment first) is to run 3 scripts:

                  1. Run the wipe.
                  2. reboot the PCs.
                  3. Re-run the wipe as per what you said before (and yes, this could probably be just the first script re-run).
                  ** Remember to give credit where credit is due and leave reputation points where appropriate **

                  Comment


                  • #10
                    Re: Script to run Symantec Cleanwipe with PsExec

                    Hi Wired

                    Thanks for your reply but step one is where I am having the problem. Cleanwipe just doesn't like it when I run it from a command line or script. It says a process has started but nothing happens.

                    When I connect to the targert machine via psexec and run cleanwipe that way then the process actually works. Why this won't work in a script is beyond me and perhaps Symantec has done this on purpose to prevent admins/users from removing symantec from systems so easily.

                    We are just going to have to split up the 400 machines between a few of us and manually start cleaning them. At least we can do it remotely

                    Thanks for all your help.

                    Comment


                    • #11
                      Re: Script to run Symantec Cleanwipe with PsExec

                      The working directory for the batch has to be set! The the 'RunCleanWipe.bat' batch is calling other batches, launching executables and append to logfiles and it's using sometimes a relative paths for it.
                      You can try this command line:
                      Code:
                      for /f "usebackq" %* in ("C:\ping\Alive.txt") do start "%*"/MIN psexec.exe \\%* cmd.exe /c pushd "c:\CleanWipe\app"^&^&"RunCleanWipe.bat" -silent
                      (note... When the above command line is used in a script/batch you need to replace %* (3 instances) with %%* )

                      EDIT, added the escape (^) signs. Without the escape signs the DO command (in for-do) wil interpreted the & signs as end_of_command_1_and_fire_a_second. The & signs are meant to group the commands that have to run on the remote machine, and therefore have to be escaped for the DO command that is running on the server.


                      After running the batch, check the logfile whether the -silent switch is used or not: c:\CleanWipe\app\logs\SAVCleanWipe.log


                      \Rems

                      When the problem eventually has solved, could you then please update the thread here or at forum.sysinternals.com and aka-community.symantec.com, with a reference to the thread that's showing the answer.
                      _
                      Last edited by Rems; 13th January 2011, 11:57.

                      This posting is provided "AS IS" with no warranties, and confers no rights.

                      __________________

                      ** Remember to give credit where credit's due **
                      and leave Reputation Points for meaningful posts

                      Comment


                      • #12
                        Re: run Symantec Cleanwipe with PsExec

                        Hi Rems

                        It seems that

                        psexec \\@Alive.txt -w c:\cleanwipe\app\ C:\CleanWipe\app\RunCleanWipe.bat -silent

                        actually works.

                        Now I need to figure out how to script the next phase instead of having to logon to every machine which kicks off a batch file called RunTwice.bat and lives in the C:\ drive after the first batch runs. This second process cleans up the rest of symantec on the pc and then reboots the pc for the last time.

                        Thanks again for your help.

                        Comment


                        • #13
                          Re: run Symantec Cleanwipe with PsExec

                          very nice!

                          to run also a second command on the remote machine, you can try something like:
                          Code:
                          psexec \\@Alive.txt -w "c:\cleanwipe\app\" cmd /c call RunCleanWipe.bat -silent ^&C:\RunTwice.bat

                          Or use a batch:
                          Code:
                          for /f "usebackq" %%* in ("C:\ping\Alive.txt") do (
                             psexec \\%%* -w "c:\cleanwipe\app\" RunCleanWipe.bat -silent
                             psexec \\%%* "C:\RunTwice.bat")

                          \Rems

                          This posting is provided "AS IS" with no warranties, and confers no rights.

                          __________________

                          ** Remember to give credit where credit's due **
                          and leave Reputation Points for meaningful posts

                          Comment

                          Working...
                          X