Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Need Script - Never Wrote One

Posted on 2011-04-20
Medium Priority
Last Modified: 2014-01-12
Very simple, I am sure, but I've viewed examples/samples online which I thought were similar to my situation but they all look different from one another, so was very tough trying to create my own from looking at others'.

I have two users in an SBS network who run Win7. I have a Kaseya agent package to install (executable) residing on the server in \docs and settings\all users\documents. I need a login script so that the agent will install automatically, in the background, once the users login to the network.

Question by:msiers
  • 2

Assisted Solution

subhashchy earned 2000 total points
ID: 35437612
what about installing the agent using the Kaseya user interface.


page 4..

Accepted Solution

subhashchy earned 2000 total points
ID: 35437633
or may be you can use this script as well..

@echo off 
If not exist "%programfiles%\kaseya\agent\agentmon.exe" \\NETBIOSDOMAINNAME\Sysvol\domain.local\scripts\customername-workstation.exe /c /e /g=customername /s /i 

Open in new window

LVL 17

Expert Comment

by:Tony Massa
ID: 35442718
FIrst, you need to determine the command required to install the software without user intervention.
Then you have to figure out what registry keys or WMI product to look for to ensure that the program doesn't try to install every time the computer starts.

Then, you write the script to:

A) Check to see if the application is already installed
 - if not -
B) Install the program

Here's a script I wrote to install SAP PDF Print component which checks to see if it's already installed first, then if it's not, checks to see if the SAPGUI client is installed (our requirement).

This should fit right in to what you need...you should just be able to change some of this stuff around to fit your needs.
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const HKEY_LOCAL_MACHINE = &H80000002
Const EVENT_FAIL = 1

On Error Resume Next

strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & _ 
    strComputer & "\root\default:StdRegProv")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objResults = objFSO.OpenTextFile("\\server\share\Install-SAP-PDF.log", ForAppending)
Set objShell = WScript.CreateObject ("WScript.shell")
Set WSHNetwork = CreateObject("WScript.Network")
strComputerName = WSHNetwork.ComputerName
'Check the following registry value to determine if SAP PDF is already installed
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SAPPdfPrint\"
strValueName = "DisplayName"
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

If IsNull(strValue) Then
	'SAP PDF programs is NOT currently installed
	'  Next, Check for SAPGUI client software
	strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\SAPGUI710\"
	strValueName = "DisplayName"
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
	If IsNull(strValue) Then
		objResults.Writeline strComputerName & vbTab & "SAP GUI Not Installed" & vbTab & Now()
		'SAP GUI is not Installed.  Requirements not met...exit script
		'SAP GUI is installed.  Continue to SAP PDF Install
		'Now copy the exe locally to the root of C:\
		objShell.Run ("xcopy \\server\shares\SAPGUI\xPDFPrint.exe c:\"),0,True
		'Install the application in SILENT mode
		Set objExec = objShell.Exec("C:\xPDFPrint.exe /Silent")
		'Check every 10 seconds to see if the installation process is complete
		Do While objExec.Status = 0
			WScript.Sleep 10000
		If objExec.ExitCode = 0 Then
			objResults.Writeline strComputerName & vbTab & "SAP PDF Component Installed" & vbTab & Now()
			objShell.LogEvent EVENT_SUCCESS, "SAP PDF Printer Installation was successful"
			objResults.Writeline strComputerName & vbTab & "SAP PDF Component Failed to Install" & vbTab & Now()
			objShell.LogEvent EVENT_FAIL, "SAP PDF Printer Installation failed with code: " & objExec.ExitCode
		End If
	End If
	objResults.Writeline strComputerName & vbTab & "SAP PDF Component Installed Previously" & vbTab & Now()
End If

Open in new window


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question