Hi - Hopefully someone can help me - I am not good with scripts - I pieced this together mostly from this forum.
I have a printer configuration (xml) file I want copied and modified to a directory. All is working fine except the filesize is changing from 5kb (original app created file) to 2kb (modified file)
The application isnt reading the 2kb file properly but if i manually copy and change the line it works fine and filesize stays at 5kb.
Please see exerpt of script below I left out a lot of the "Case" lines - Keep in mind i have no idea what i'm doing before hating on my scripting - Thanks in advance!!!
option explicit
Dim oShell Dim sWkstName Dim sDefaultLabelPrinter Dim sKeyName Dim bGo Dim xmlDoc Dim nPrinterName Dim WshShl Dim Shell Dim UserVar Dim WshShell Dim objFSO
Set oShell = CreateObject("WScript.Shell")
sWkstName = oShell.ExpandEnvironmentStrings("%CLIENTNAME%")
' map Workstation to Shared Printer bGo = True
Select Case sWkstName
Case "SJH-G505-92" ' ShawnTest
sDefaultLabelPrinter = "SmartLabel-Office-Nancy"
Case Else bGo = False MsgBox("DEFAULT LABEL PRINTER NOT SET FOR THIS COMPUTER") End select
If bGo = True Then
' set default label printer to use Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False" xmlDoc.Load("C:\ProgramData\Smart Label Printer\SlpConfig.xml")
Set nPrinterName = xmlDoc.selectsinglenode("//InstalledPrinter/PrinterName")
nPrinterName.text = sDefaultLabelPrinter
Set WshShell = WScript.CreateObject("Wscript.Shell") UserVar = WshShell.ExpandEnvironmentStrings("%APPDATA%")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Check if file exists to prevent error If objFSO.FileExists(UserVar & "\Smart Label Printer\SlpConfig.xml") Then objFSO.DeleteFile(UserVar & "\Smart Label Printer\SlpConfig.xml") End If
xmlDoc.PreserveWhitespace = true xmlDoc.Save UserVar & "\Smart Label Printer\SlpConfig.xml" end if
WScript.Quit
|
|