Page 1 of 1 1
Topic Options
#206200 - 2012-11-12 04:10 PM Need help converting batch script to Kix
imasri Offline
Just in Town

Registered: 2012-11-09
Posts: 2
Loc: New Jersey, USA
Hello, I need some help taking the batch script below and making it a kixtart script. Any help would be greatly appreciated.

++++++++++++++++++++++++++++++++script below+++++++++++++++++++++++++++++++++++++++
 Code:
@echo off

::Create Log file of script actions
IF NOT EXIST "C:\Logs\Altiris Install" (
	md "C:\Logs\Altiris Install"
	TIME /T>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	echo 1a-Made Log file of install Altiris 7.1 Agents SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
) ELSE ( 
	TIME /T>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	echo 1a-Altiris INSTALL Log directory already exists.>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
)

IF EXIST "C:\Program Files\Altiris\Altiris Agent\Agents\Agent Tasks\BaseTaskHandlers.dll" (
	echo 1b-BaseTaskHandlers DLL already exists. Go to next check>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :check1	
) ELSE (
	echo 1b-BaseTaskHandlers DLL does not exist.  Altiris will do clean uninstall and then reinstall>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist
)

:check1
IF EXIST "C:\Program Files\Altiris\Altiris Agent\Agents\Client Task Agent\Client Task Agent.dll" (
	echo 1c-Client Task Agent DLL already exists. Go to next check>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :check2
) ELSE (
	echo 1c-Client Task Agent DLL does not exist.  Altiris will do clean uninstall and then reinstall>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist
)

:check2
IF EXIST "C:\Program Files\Altiris\Altiris Agent\Agents\Inventory Agent\InvAgent.dll" (
	echo 1d-InvAgent DLL already exists. Go to next check>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :check3
) ELSE (
	echo 1d-InvAgent DLL does not exist.  Altiris will do clean uninstall and then reinstall>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist
)

:check3
IF EXIST "C:\Program Files\Altiris\Altiris Agent\Agents\PowerSchemeAgent\PowerSchemeAgent.dll" (
	echo 1e-PowerSchemeAgent DLL already exists. Go to next check>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :check4
) ELSE (
	echo 1e-PowerSchemeAgent DLL does not exist.  Altiris will do clean uninstall and then reinstall>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist
)

:check4
IF EXIST "C:\Program Files\Altiris\Altiris Agent\Agents\SoftwareManagement\SMFAgent.dll" (
	echo 1f-SMFAgent DLL already exists. Go to next check>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :check5
) ELSE (
	echo 1f-SMFAgent DLL does not exist.  Altiris will do clean uninstall and then reinstall>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist
)

:check5
IF EXIST "C:\Program Files\Altiris\Altiris Agent\Agents\Software Management Solution Plugin\SoftwareManagementSolution_Agent.dll" (
	echo 1g-SoftwareManagementSolutionAgent DLL already exists. Go to next check>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :check6
) ELSE (
	echo 1g-SoftwareManagementSolutionAgent DLL does not exist.  Altiris will do clean uninstall and then reinstall>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist
)

:check6
IF EXIST "C:\Program Files\Altiris\Altiris Agent\Agents\Application Metering Agent\AMAgent.dll" (
	echo 1h-AMAgent DLL already exists. Go to next check>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :check7
) ELSE (
	echo 1h-AMAgent DLL does not exist.  Altiris will do clean uninstall and then reinstall>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist
)

:check7
IF EXIST "C:\Program Files\Symantec\pcAnywhere\pcAAgent.dll" (
	echo 1i-pcAAgent DLL already exists. Go to next check>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :check8
) ELSE (
	echo  1i-pcAAgent  DLL does not exist.  Altiris will do clean uninstall and then reinstall>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist
)

:check8
IF EXIST "C:\Program Files\Altiris\Altiris Agent\Agents\Deployment\Agent\DeploymentSolutionAgent.dll" (
	echo 1j-DeploymentSolutionAgent DLL already exists. Go to next check>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	echo ****************************************************************************** >>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	echo *       Altiris NS 7.1 already installed on this machine. Done checking      *>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	echo ****************************************************************************** >>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :end
) ELSE (
	echo 1j-DeploymentSolutionAgent does not exist.  Altiris will do clean uninstall and then reinstall>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist
)

:Checkifexist
IF EXIST "c:\Program Files\Altiris Agent\AeXAgentUtil.exe" (
	echo 2-Uninstall utility available to begin>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :remove
) ELSE (
	echo 2-Uninstall utility  NOT available. Download from server will begin begin>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :Checkifexist2
)

:Checkifexist2
IF NOT EXIST "C:\Program Files\Altiris\Altiris Agent" (
	md "C:\Program Files\Altiris\Altiris Agent"
	echo 2a-Missing Altiris Agent Folder created new SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	copy \\njnas01\ApplicationsFS\Apps\Symantec\Altiris\7.1\Install\EXE\aexnsc.exe "C:\Program Files\Altiris\Altiris Agent"
	echo 2b-Copy of uninstall EXE to Altiris Directory SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :remove
) ELSE ( 
	echo 2a-Altiris Folder Directory already exists.>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
	GOTO :remove
)

:remove
echo 3-Start of Clean removal of all Old Altiris Agents SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
c:\"Program Files"\Altiris\"Altiris Agent"\AeXAgentUtil.exe /uninstallagents /clean

::Installation of New Altiris 7.1
md c:\Windows\System32\AltirisUpgrade
echo 4-Made Temporary Directory to Install Altiris 7.1 Agents SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
copy \\njnas01\ApplicationsFS\Apps\Symantec\Altiris\7.1\Install\EXE\aexnsc.exe "c:\Windows\System32\AltirisUpgrade"
echo 5-Copy of Install EXE to Temp Directory SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
echo 6-Performing wait time during completion of uninstall SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
c:\Windows\System32\PING 127.0.0.1 -n 60 >NUL
echo 7-Start of Install for Altiris 7.1 Agents SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
c:\Windows\System32\AltirisUpgrade\aexnsc.exe -s ns="NJCMSSRV01.spectraeastnj.com"
echo 8-Performing wait time during completion of install SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
c:\Windows\System32\PING 127.0.0.1 -n 240 >NUL

::Popup Message.
MSG * "Your workstation has been Upgraded to Altiris 7.1"
RMDIR /S /Q c:\windows\System32\AltirisUpgrade
echo 9-Removal of all temp files during install SUCCESSFUL>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
echo ****************************************************************************** >>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
echo *           Workstation has been Upgraded to Altiris 7.1 SUCCESSFUL       *>>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
echo ****************************************************************************** >>"C:\Logs\Altiris Install\InstallLog_altiris7.1.txt"
:end


Edited by Allen (2012-11-12 04:26 PM)
Edit Reason: added code tags

Top
#206201 - 2012-11-12 04:38 PM Re: Need help converting batch script to Kix [Re: imasri]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
http://www.kixtart.org/?p=commandRef

the command reference has examples for your used commands if, exist, md... del will remove directories.
echo is not needed as anything is echoed to the console if output is not suppressed.

you are running ping and what not. for running them commands, use shell, examples in the command ref.
_________________________
!

download KiXnet

Top
#206202 - 2012-11-12 04:42 PM Re: Need help converting batch script to Kix [Re: Lonkero]
imasri Offline
Just in Town

Registered: 2012-11-09
Posts: 2
Loc: New Jersey, USA
Thank you for the command reference Lonkero, but I am very unfamiliar with syntax in Kixtart. I don't know how it would end up looking, or how to begin converting. Can someone assist with helping re-code it to Kixtart?
Top
#206203 - 2012-11-12 05:59 PM Re: Need help converting batch script to Kix [Re: imasri]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Like I said, the command reference has examples.
so what part is that you don't understand?
_________________________
!

download KiXnet

Top
#206204 - 2012-11-12 08:49 PM Re: Need help converting batch script to Kix [Re: Lonkero]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4400
Loc: New Jersey
Most commands are ALMOST 1:1, so this should be fairly easy.

Eliminate the parens around IF/Else, and add an EndIf to close the statement..

Remove "Echo" and add quotes around the message to display, and a "?" or "@CRLF" for a CR/LF at the end.

Use "RedirectOutput(filename)" to send messages to a log file, then repeat the command without a file name to end redirection.

"Exist file" is replaced with Exist(File)

So, if you look up every command (except Echo) you'll find a corresponding Kix command with similar syntax.

Goto's are frowned upon - once you have some code hacked togeher, we'll provide some alternatives to eliminate them.

Give these a try and then post your code to ask specific questions. We'll be happy to provide assistance rather than simply handing someone a complete solution.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 323 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.055 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org