Update Line from LANDesk Actions.ini File

email me

This will uppdate the line containing SDCLIENTRECONNECT from the LANDesk actions.ini file. It adds missing double quotes.

From

SDCLIENTRECONNECT=C:\Program Files (x86)\LANDesk\LDClient\sdclient.exe /policyfile=”” /reconnect

To

SDCLIENTRECONNECT=C:\Program Files (x86)\LANDesk\LDClient\sdclient.exe /policyfile=”” /reconnect

Option Explicit 

Dim txtFile, oFSO, oFile, txtLine, modifiedFile, modLineContaining, replacementLine

Const ForReading = 1
Const ForWriting = 2

txtFile = "C:\Program Files (x86)\LANDesk\Shared Files\cbaroot\actions.ini"
modLineContaining = "SDCLIENTRECONNECT"

replacementLine = "SDCLIENTRECONNECT=""C:\Program Files (x86)\LANDesk\LDClient\sdclient.exe"" /policyfile="""" /reconnect"

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.OpenTextFile(txtFile, ForReading)

Do Until oFile.AtEndOfStream
    txtLine = oFile.ReadLine
    If InStr(txtLine, modLineContaining) = 0 Then
        modifiedFile = modifiedFile & txtLine & vbCrLf
	else
		modifiedFile = modifiedFile & replacementLine & vbCrLf
    End If
Loop

oFile.Close

Set oFile = oFSO.OpenTextFile(txtFile, ForWriting)

oFile.Write modifiedFile
oFile.Close

'session clean up
txtFile = ""
txtLine = ""
txtLine = ""
modifiedFile = ""
modLineContaining = "" 
replacementLine = ""
set oFSO = Nothing
set oFile = Nothing

WScript.Quit(0)

 
Also see Remove Line from LANDesk Actions.ini File

 
Notes

Client Issue

When a LANDesk package is pushed and there is a pending update, the SDCLIENTRECONNECT line is generated.

Once this line exists, no other packages can be pushed until one of two things happen:

#1 The machine is rebooted. Once rebooted, the SDCLIENTRECONNECT line is cleared and packages can be pushed.

#2 Add quotes around Program Files (x86), just like the other lines. When quotes are added, packages can be pushed.

 
Technical Problem

Missing quotes on the SDCLIENTRECONNECT line if forcing unnecessary reboots.

 
Solution

Add quotes to generated line.

Screenshot