Right-trimming text files
If you're going to be writing VBScript or WSScript files then you should be using VBEdit.


Allow it is not required you should still capitalize End, Function and Sub.
Wrapping each tasks in it's own Sub or Function will make it easier to read, debug and modify your code.
A Function that does not return a value should be a Sub.
Avoid editing text files line by line.  It is much more efficient to split the text into an array of lines, edit each element of the array, and then join the output.
Refactored Code
This code takes less than 1 second to trim each line of a 27 MB text file.
Dim FullFileName
FullFileName = GetSharedFileName

If FileSystemObject.FileExists(FullFileName) Then
    TrimFileContents FullFileName
    MsgBox &quot;Done&quot;
Else
    MsgBox &quot;File not found: &quot; &amp; FullFileName
End If


Sub TrimFileContents(FullFileName)
    Dim Lines
    Lines = GetTextFileLines(FullFileName)
    
    Dim n

    For n = 0 To UBound(Lines)
        Lines(n) = Trim(Lines(n))
    Next
    
    OverWriteTextFile FullFileName, Join(Lines, vbNewLine)
End Sub

Function GetSharedFileName
    GetSharedFileName = Replace(GetParentFolderName,&quot;jobs\SCRIPTS&quot;,&quot;shared\file&quot;) &amp; &quot;\DCS.txt&quot;
End Function

Function FileSystemObject
    Set FileSystemObject = CreateObject(&quot;Scripting.FileSystemObject&quot;)
End Function


Function GetParentFolderName

    GetParentFolderName = FileSystemObject.GetFile(Wscript.ScriptFullName).ParentFolder.Path

End Function

Function GetTextFileLines(FullFileName)
    Const ForReading = 1
    Dim Text
    With FileSystemObject.OpenTextFile(FullFileName, ForReading)
        Text = .ReadAll
        .Close
    End With
    
    If InStr(Text, vbNewLine) = 0 Then
        GetTextFileLines = Split(Text, vbLf)
    Else
        GetTextFileLines = Split(Text, vbNewLine)
    End If

End Function

Sub OverWriteTextFile(FullFileName, Text)
    Const ForWriting = 2

    With FileSystemObject.OpenTextFile(FullFileName, ForWriting)
        .Write Text
        .Close
    End With
    
End Sub