Need Script - Never Wrote One

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.

Thanks.
msiersAsked:
Who is Participating?
 
subhashchyCommented:
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

0
 
subhashchyCommented:
what about installing the agent using the Kaseya user interface.

http://www.cloudservicesdepot.com/files/docs/Kaseya_Getting_Started_Guide.pdf 

page 4..
0
 
Tony MassaCommented:
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_SUCCESS = 0
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()
		objResults.Close
		'SAP GUI is not Installed.  Requirements not met...exit script
		WScript.Quit(0)
	Else
		'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
		Loop
		err.Clear
		If objExec.ExitCode = 0 Then
			objResults.Writeline strComputerName & vbTab & "SAP PDF Component Installed" & vbTab & Now()
			objResults.Close
			objShell.LogEvent EVENT_SUCCESS, "SAP PDF Printer Installation was successful"
			objFSO.DeleteFile("c:\xPDFPrint.exe")
		Else
			objResults.Writeline strComputerName & vbTab & "SAP PDF Component Failed to Install" & vbTab & Now()
			objResults.Close
			objShell.LogEvent EVENT_FAIL, "SAP PDF Printer Installation failed with code: " & objExec.ExitCode
			objFSO.DeleteFile("c:\xPDFPrint.exe")
		End If
	End If
Else
	objResults.Writeline strComputerName & vbTab & "SAP PDF Component Installed Previously" & vbTab & Now()
	objResults.Close
End If

Open in new window

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.