Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...My thanks to the contributors who freely share their knowledge and enthusiasms. This forum restores some measure of my faith in human nature..."

Geography

Where in the world do Tek-Tips members come from?
Fletche (MIS)
6 Mar 12 17:04
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


 

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close