Kaseya Community

Help with execute command shell

  • Hoping someone can help me with my script I'm writing, script is to upgrade client machine's Symantec Endpoint protection. In theory it should check for the setup file on the network server, if its not there download it from our website and retry again in 10 minutes. If it is there it checks for 7zip, installs if not there, copies the setup file to the local temp drive, unzips it with 7zip and then executes the setup file. Problem I am having is with the execute command shell steps, they don't seem to be doing anything. If I run the same commands from CMD on the local machine they work fine, just not in the script.

    the two commands not working are
    xcopy \SEP.7z #temp#
    "%programfiles%\7-zip\7z.exe" e c:\temp\SEP.7z -oc:\temp\SEP -r -y

    I'm still a bit of scripting n00b so I'm sure it's something really simple I've missed.

    Full scripts below

    Script Name: SC_SEP Upgrade
    Script Description: Checks for file on server and uploads if not there, if there, copies to local HDD unzips, installs, notifies user, and deletes install folder.

    IF Test File
    Parameter 1 : \SEP.7z
    Exists :
    THEN
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : temp
    OS Type : 0
    Execute Script
    Parameter 1 : SC_7-Zip Installer (NOTE: Script reference is NOT imported. Correct manually in script editor.
    Parameter 2 :
    Parameter 3 : 0
    OS Type : 0
    Execute Shell Command
    Parameter 1 : xcopy \SEP.7z #temp#
    Parameter 2 : 0
    OS Type : 0
    Execute Shell Command
    Parameter 1 : "%programfiles%\7-zip\7z.exe" e #temp#\SEP.7z -o#temp#\SEP -r -y
    Parameter 2 : 0
    OS Type : 0
    Execute File
    Parameter 1 : #temp#\SEP\setup.exe
    Parameter 2 : /s /v"/L*V log.txt /qn RUNLIVEUPDATE=1 REBOOT=REALLYSUPRESS"
    Parameter 3 : 1
    OS Type : 0
    Send Message
    Parameter 1 : Your AntiVirus has been upgraded to the latest Version, please restart your machine at the next available time to finalize changes. If you have any questions please call the ****** Helpdesk on ** *** ****.
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : rmdir /sq c:\temp\SEP
    Parameter 2 : 1
    OS Type : 0
    ELSE
    Get URL
    Parameter 1 : http://www.******.co.nz/SEP.7z
    Parameter 2 : \SEP.7z
    Parameter 3 : 3
    OS Type : 0
    Schedule Script
    Parameter 1 : 65068019
    Parameter 2 : 10
    Parameter 3 :
    OS Type : 0


    Script Name: SC_7-Zip Installer
    Script Description: This script downloads the 7-Zip installer file directly from the internet to the target machine and then runs the installer in silent mode. The machine will require direct port 80 access to internet to do this. Or download the file to Kaseya Managed Files directory, and change step 2 to a Write file command to write the file to the target machine. The Steps to install from a file share are also included, just disabled. If you prefer to install from a fileshare on the local LAN rather than have each machine download directly, just disable the download step (step 2) and enable the other currently disabled steps (Step 3 & 4), and enter your local network share details in step 4. Make sure you have a credential stored for your machines to use under the Agent->Set Credential funciton, a Domain Administrator credential is best. Please view 7-zip license here: http://www.7-zip.org/license.txt

    IF Test File
    Parameter 1 : %programfiles%\7-zip\7z.exe
    Absent :
    THEN
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : ktemp
    OS Type : 13
    Get URL
    Parameter 1 : http://kent.dl.sourceforge.net/sourceforge/sevenzip/7z458.exe
    Parameter 2 : #ktemp#\7zipinstaller.exe
    Parameter 3 : 3
    OS Type : 13
    Use Credential
    OS Type : -1
    Execute Shell Command
    Parameter 1 : xcopy \\INSERT-SERVER-ADDRESS\INSERT-SHARE-NAME\7z457.exe #ktemp#\7zipinstaller.exe /y
    Parameter 2 : 0
    OS Type : -1
    Execute File
    Parameter 1 : #ktemp#\7zipinstaller.exe
    Parameter 2 : /S
    Parameter 3 : 1
    OS Type : 13
    Get Variable
    Parameter 1 : 6
    Parameter 2 :
    Parameter 3 : machineID
    OS Type : 13
    Write Script Log Entry
    Parameter 1 : 7Zip archive tool installer executed on machine #machineID#
    OS Type : 13
    ELSE
    Write Script Log Entry
    Parameter 1 : 7Zip already installed
    OS Type : 0


    Legacy Forum Name: Help with execute command shell,
    Legacy Posted By Username: FITSteven
  • I'll update this post later when I get a chance to post my test code for the 7z via command line, but I do believe that you need to use the 7z command line version
    located here

    Almost forgot


    Script Name: 7zip test
    Script Description: Example script for 7z unzipping

    IF True
    THEN
    Write File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\7za.exe
    Parameter 2 : VSASharedFiles\Applications\7zip\7za.exe
    OS Type : 0
    Get URL
    Parameter 1 : http://www.cetratechnology.com/downloads/test.exe
    Parameter 2 : #vAgentConfiguration.agentTempDir#\test.7z
    Parameter 3 : 3
    OS Type : 0
    Execute File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\7za.exe
    Parameter 2 : x -o#vAgentConfiguration.agentTempDir#\test\ #vAgentConfiguration.agentTempDir#\test.7z
    Parameter 3 : 1
    OS Type : 0
    Delete File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\7za.exe
    OS Type : 0
    Delete File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\test.7z
    OS Type : 0
    ELSE


    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: thirteentwenty
  • Thanks for that, still couldnt get the xcopy command to work for some reason but figured a workaround for that

    Script Name: SC_SEP Upgrade
    Script Description: Checks for file on server and uploads if not there, if there, copies to local HDD unzips, installs, notifies user, and deletes install folder.

    IF Test File
    Parameter 1 : \SEP.7z
    Exists :
    THEN
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : temp
    OS Type : 0
    Write File
    Parameter 1 : #temp#\7za.exe
    Parameter 2 : VSASharedFiles\7zip\7za.txt
    OS Type : 0
    Execute File
    Parameter 1 : #temp#\7za.exe
    Parameter 2 : x -o#temp#\SEP\ \SEP.7z
    Parameter 3 : 1
    OS Type : 0
    Execute File
    Parameter 1 : #temp#\SEP\SEP\setup.exe
    Parameter 2 : /s /v"/L*V log.txt /qn RUNLIVEUPDATE=1 REBOOT=REALLYSUPRESS"
    Parameter 3 : 1
    OS Type : 0
    Send Message
    Parameter 1 : Your AntiVirus has been upgraded to the latest Version, please restart your machine at the next available time to finalize changes. If you have any questions please call the ******* Helpdesk on ********.
    Parameter 2 : 1
    OS Type : 0
    Execute Shell Command
    Parameter 1 : rmdir /sq c:\temp\SEP
    Parameter 2 : 1
    OS Type : 0
    ELSE
    Get URL
    Parameter 1 : http://www.*******.co.nz/SEP.7z
    Parameter 2 : \SEP.7z
    Parameter 3 : 3
    OS Type : 0
    Schedule Script
    Parameter 1 : 65068019
    Parameter 2 : 10
    Parameter 3 :
    OS Type : 0


    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: FITSteven
  • You never did mention what kind of box this is... and by the by, I think robocopy is the prefered method (and replacement to xcopy)

    Also this is from a different thread (to help make scripts a bit more import friendly)


    #patchparams.sourcepath#


    That gives you your patch location, that way you dont have to change it every time you run the script on a different client etc etc etc

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: thirteentwenty