Script to set Norton Security Suite update frequency - Overclock.net - An Overclocking Community
Forum Jump: 

Script to set Norton Security Suite update frequency

 
Thread Tools
post #1 of 5 (permalink) Old 05-09-2016, 04:54 AM - Thread Starter
Overclock Failed...
 
billbartuska's Avatar
 
Join Date: Mar 2005
Location: Greater Chicagoland Area
Posts: 13,565
Rep: 1249 (Unique: 969)
This batch file causes Notron Security Suite to update its virus definition file(s) and logs the update to a text file

I use it as a scheduled task to control and monitor how often the updating is done.
As an aside, every four hours seems sufficient.
Code:
@ECHO OFF
:--------------------------------------------------------------------
REM Get PID for n360.exe >FindPID.txt
TASKLIST /FI "IMAGENAME eq n360.exe"
:--------------------------------------------------------------------
REM Logs when run
set logfile=C:\Users\Bill\Desktop\NortonUpdates.log
echo Run on %date% at %time% >>C:\Users\Bill\Desktop\NortonUpdates.log
:--------------------------------------------------------------------
REM  --> Run Norton Live Update Batch file as Admin
goto NEXT
:NEXT
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
:--------------------------------------------------------------------
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:-----------------------------------------------------------------------------
REM Run Update Then Kill It 
"C:\Program Files (x86)\Norton Security Suite\Engine64\22.6.0.142\uistub.exe" /lu
TIMEOUT 30
TASKKILL /PID 4612
REM TASKKILL /n360.exe

The problem I'm having is with the third line from the bottom that kills the Norton update task when the script ends. (ie. closes the desktop "update complete" window)

The PID changes with every restart/reboot so I have to manually edit the script when that happens.

The fourth line displays the current PID and the 30 second TIMEOUT leaves enough time to do the edit/save while the batch file is executing.

So, how can I automate the kill process so that it gets the current PID and the batch file works without manual editing after each restart/reboot (ie. when the PID changes)?

I've been searching for months and can't seem to find an answer.

Your help will be greatly appreciated!
 
 
 

https://www.overclock.net/images/smil...lame-small.gif5 GHz Overclock Club https://www.overclock.net/images/smil...lame-small.gifMisinformation is available from a variety of other sources. Misinformation is just like real information but wrong
....and enough power to shoot the speaker cones through the walls.
billbartuska is offline  
Sponsored Links
Advertisement
 
post #2 of 5 (permalink) Old 05-10-2016, 11:21 PM
New to Overclock.net
 
agawthrop's Avatar
 
Join Date: Nov 2014
Location: Huntington, WV
Posts: 242
Rep: 51 (Unique: 18)
The following should do what you want
Code:
@ECHO OFF
:--------------------------------------------------------------------
REM Get PID for n360.exe >FindPID.txt
TASKLIST /FI "IMAGENAME eq n360.exe"
for /f "tokens=2" %%a in ('tasklist /nh /fi "imagename eq n360.exe"') do (SET /A ProcessID=%%a)
:--------------------------------------------------------------------
REM Logs when run
set logfile=C:\Users\Bill\Desktop\NortonUpdates.log
echo Run on %date% at %time% >>C:\Users\Bill\Desktop\NortonUpdates.log
:--------------------------------------------------------------------
REM  --> Run Norton Live Update Batch file as Admin
goto NEXT
:NEXT
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
:--------------------------------------------------------------------
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:-----------------------------------------------------------------------------
REM Run Update Then Kill It 
"C:\Program Files (x86)\Norton Security Suite\Engine64\22.6.0.142\uistub.exe" /lu
TIMEOUT 30
TASKKILL /PID %ProcessID%
REM TASKKILL /n360.exe
agawthrop is offline  
post #3 of 5 (permalink) Old 05-11-2016, 03:17 AM - Thread Starter
Overclock Failed...
 
billbartuska's Avatar
 
Join Date: Mar 2005
Location: Greater Chicagoland Area
Posts: 13,565
Rep: 1249 (Unique: 969)
AHHHH!

do (SET /A ProcessID=%%a)

Thanks a bezillion!

https://www.overclock.net/images/smil...lame-small.gif5 GHz Overclock Club https://www.overclock.net/images/smil...lame-small.gifMisinformation is available from a variety of other sources. Misinformation is just like real information but wrong
....and enough power to shoot the speaker cones through the walls.
billbartuska is offline  
Sponsored Links
Advertisement
 
post #4 of 5 (permalink) Old 05-11-2016, 07:26 AM
New to Overclock.net
 
agawthrop's Avatar
 
Join Date: Nov 2014
Location: Huntington, WV
Posts: 242
Rep: 51 (Unique: 18)
I know this wasn't requested, but I cleaned up the bat file and updated some of the methods being used (i.e. checking for privileges). You can use it if you like, if not no big deal. I will note that I haven't test with the norton program as I don't have that, but I did test with notepad to make sure it did what I wanted.

I've essentially made it more universal so that if the task name, program location, program arguments, desired log location changes, you can make those tweaks right at the top of the file.
Code:
SetLocal EnableDelayedExpansion EnableExtensions
@Echo Off
Cls

Set _taskName=n360.exe
Set _program="C:\Progam Files (x86)\Norton Security Suite\Engine64\22.6.0.142\uistub.exe"
Set _args=/lu
Set _logFile="%userprofile%\Desktop\NortonUpdates.log"
Set _exDate=%date%
Set _exTime=%time%

REM Get PID for specified task
For /f "tokens=2" %%a In ('tasklist /nh /fi "imagename eq %_taskName%"') Do (Set /a _processID=%%a)

REM Log date & time when executed
Echo Run on %_exDate% at %_exTime% >>%_logFile%

GoTo checkServerService

REM Verifies that the server service is running so we can use net session to check privileges
:checkServerService
        Set _server=LanmanServer
        Echo Verifying Server service is running...
        For /F "tokens=3 delims=: " %%H In ('sc query %_server% ^| Findstr "STATE"') Do ( 
                If /I "%%H" NEQ "RUNNING" ( 
                        Echo Starting Server service...
                        net start %_server%
                )
        )
        Goto verifyPrivileges

REM Verifies that the CMD window has been opened with proper privileges
:verifyPrivileges
    Echo Administrative privileges required. Verifying privileges...
        net session >Nul 2>&1
    If %errorLevel% == 0 (
        Echo Privileges verified.
        GoTo gotAdmin
    ) Else (
                Echo Privilege not verified.
                Echo Program will restart as administrator...
                GoTo getAdmin
    )
REM Reopens script in with admin privileges
:getAdmin
        Set getAdminScript="%temp%\%Random%-%Random%-%Random%-%Random%.vbs"
    Echo Set UAC = CreateObject^("Shell.Application"^) > %getAdminScript%
    Echo args = "" >> %getAdminScript%
    Echo For Each strArg in WScript.Arguments >> %getAdminScript%
    Echo args = args ^& strArg ^& " "  >> %getAdminScript%
    Echo Next >> %getAdminScript%
    Echo UAC.ShellExecute "%~s0", args, "", "runas", 1 >> %getAdminScript%

    %getAdminScript% %*
        Exit /B
REM Deletes temp script
:gotAdmin
    If Exist %getAdminScript% ( Del %getAdminScript% )
    pushd "%CD%"
    CD /D "%~dp0"
        GoTo runUpdate

REM Run Update
:runUpdate
        Echo Executing program...
        %_program% %_args%
        Echo Program finished.
        Taskkill /PID %_processID%
        GoTo Exit
        
:Exit
        For /F %%# In ('Copy /z "%~dpf0" NUL') Do Set "CR=%%#" 
        For /L %%# In (30,-1,1) Do (Set /P "=This program will close in %%# seconds. !CR!"<Nul: 
                >Nul Timeout /T 1)
        Exit
:eof
agawthrop is offline  
post #5 of 5 (permalink) Old 05-13-2016, 12:52 AM - Thread Starter
Overclock Failed...
 
billbartuska's Avatar
 
Join Date: Mar 2005
Location: Greater Chicagoland Area
Posts: 13,565
Rep: 1249 (Unique: 969)
Again, thanks, I'll check it out.

https://www.overclock.net/images/smil...lame-small.gif5 GHz Overclock Club https://www.overclock.net/images/smil...lame-small.gifMisinformation is available from a variety of other sources. Misinformation is just like real information but wrong
....and enough power to shoot the speaker cones through the walls.
billbartuska is offline  
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off