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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
The Five Tenets of the Most Secure Backup

Data loss can hit a business in any number of ways. In reality, companies should expect to lose data at some point. The challenge is having a plan to recover from such an event.

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
wajhiuddinAuthor 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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.