bat file to copy sylink file

I  need to run this bat file to copy sylink file on windows 7 32 and 64 bit.

following command should run if system is 32 bit
"%programfiles%\symantec\symantec endpoint protection\smc.exe" –stop

If it's 64 bit it should run
"%programfiles(x86)%\symantec\symantec endpoint protection\smc.exe" –stop

this command should run on both OS

copy sylink.xml "C:\ProgramData\Symantec\Symantec Endpoint Protection\CurrentVersion\Data\Config\"

Attached bat file runs perfectly fine on both OSs but I get an error mesage at one point which I am trying to avoid.
F--Sylink.txt
wajhiuddinAsked:
Who is Participating?
 
NVITConnect With a Mentor Commented:
Does this help?
if "%programfiles(x86)%" neq "" 
  echo "%programfiles(x86)%\symantec\symantec endpoint protection\smc.exe" -stop
  echo Put other 64 bit code here
) else (
  echo "%programfiles%\symantec\symantec endpoint protection\smc.exe" -stop
  echo Put other 32 bit code here
)

Open in new window

0
 
Bill PrewCommented:
Here's a simple approach...

@echo off

if exist "%programfiles%\symantec\symantec endpoint protection\smc.exe" (
    "%programfiles%\symantec\symantec endpoint protection\smc.exe" –stop
) else (
    "%programfiles(x86)%\symantec\symantec endpoint protection\smc.exe" –stop
)

copy sylink.xml "C:\ProgramData\Symantec\Symantec Endpoint Protection\CurrentVersion\Data\Config\"

if exist "%programfiles%\symantec\symantec endpoint protection\smc.exe" (
    "%programfiles%\symantec\symantec endpoint protection\smc.exe" –start
) else (
    "%programfiles(x86)%\symantec\symantec endpoint protection\smc.exe" –stop
)

exit

Open in new window


»bp
0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
Just a question... Why not use the Sylinkdrop.exe tool? Is can be used from the command line
https://www.symantec.com/connect/articles/step-step-guide-use-sylinkdropexe
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
wajhiuddinAuthor Commented:
shaun Vermaak , we need to replaced sylink on thousands of comoputers
0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
You can still use sylinkdrop to do it.

Deploy sylink and sylinkdrop.exe via GPO file preference and execute via a GPO preference scheduled task

File and Schedule Task preferences can be done similarly to the last part of this article
https://www.experts-exchange.com/articles/31687/Windows-Firewall-as-Code.html
0
 
wajhiuddinAuthor Commented:
NVIT , your command works perfect, I just need to add a line
rename  sylink.xml  sylink.back "C:\ProgramData\Symantec\Symantec Endpoint Protection\CurrentVersion\Data\Config\"

Before
copy sylink.xml "C:\ProgramData\Symantec\Symantec Endpoint Protection\CurrentVersion\Data\Config\"

but getting an error message "the syntax of the command is incorrect "
0
 
Bill PrewCommented:
Try this.  It will make sure there isn't already a sylink.back file there (which would cause the RENAME to fail), and if there is deletes it first.  Then renames the current one, and does the copy.

if exist "C:\ProgramData\Symantec\Symantec Endpoint Protection\CurrentVersion\Data\Config\sylink.back" del "C:\ProgramData\Symantec\Symantec Endpoint Protection\CurrentVersion\Data\Config\sylink.back"
rename  "C:\ProgramData\Symantec\Symantec Endpoint Protection\CurrentVersion\Data\Config\sylink.xml" sylink.back
copy sylink.xml "C:\ProgramData\Symantec\Symantec Endpoint Protection\CurrentVersion\Data\Config\"

Open in new window


»bp
0
 
wajhiuddinConnect With a Mentor Author Commented:
Bill Prew
rename  "C:\ProgramData\Symantec\Symantec Endpoint Protection\CurrentVersion\Data\Config\sylink.xml" sylink.back


error appears "syatem can't find the path" ???
0
 
wajhiuddinAuthor Commented:
Thanks for all  your help
0
 
Bill PrewCommented:
Okay, I assumed there would always be a sylink.xml existing, this will only do the rename when that is true.

Also adding a variable for the Symantec folder involved, to make the code a bit more readbale...

setlocal
set SymDir=%SymDir%

if exist "%SymDir%\sylink.back" del "%SymDir%\sylink.back"
if exist "%SymDir%\sylink.xml" rename  "%SymDir%\sylink.xml" sylink.back
copy sylink.xml "%SymDir%\"

Open in new window


»bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.