I am creating a script that will automatically deploy a common *.pac file (for proxy settings) to four different webservers across two datacenters.
Everything in the script works, except the file copy.
The testdeploydc.pac and testdeploysdc.pac files are 8k, but they copy to the destination folders as empty files.
Another thing to probably note is that this script is being "runas" another user (runas user with privs to write to destination).
How do I get these to copy correctly?
Script follows:
Everything in the script works, except the file copy.
The testdeploydc.pac and testdeploysdc.pac files are 8k, but they copy to the destination folders as empty files.
Another thing to probably note is that this script is being "runas" another user (runas user with privs to write to destination).
How do I get these to copy correctly?
Script follows:
Code:
Const ForReading = 1
Const ForWriting = 2
strFileSourcePath = "proxy.pac"
strFileTargetPathDC = "testdeploydc.pac"
strFileTargetPathSDC = "testdeploysdc.pac"
strFileTargetPath = "E$\webroot\proxy\testdeploy.pac"
strPathDC12p = "\\server12p\"
strPathDC13p = "\\server13p\"
strPathSDC14p = "\\server14p\"
strPathSDC15p = "\\server15p\"
added = false
on error resume next
Set objFSOSource = CreateObject("scripting.filesystemobject")
Set objFSOTargetDC = CreateObject("scripting.filesystemobject")
Set objFSOTargetSDC = CreateObject("scripting.filesystemobject")
Set objFilesSource = objFSOSource.OpenTextFile(strFileSourcePath,ForReading,True,0)
Set objFilesTargetDC = objFSOTargetDC.OpenTextFile(strFileTargetPathDC,ForWriting,True,0)
Set objFilesTargetSDC = objFSOTargetSDC.OpenTextFile(strFileTargetPathSDC,ForWriting,True,0)
Set fso = CreateObject("Scripting.FileSystemObject")
Do While objFilesSource.AtEndOfStream <> True
strCurrentLine = objFilesSource.ReadLine
if ((InStr(1,strCurrentLine,"use_proxy",1) > 0) AND (added = false)) then
objFilesTargetDC.WriteLine " var use_proxy = proxy_dc;"
objFilesTargetSDC.WriteLine " var use_proxy = proxy_sdc;"
added = true
else
objFilesTargetDC.WriteLine strCurrentLine
objFilesTargetSDC.WriteLine strCurrentLine
end if
Loop
objFilesSource.Close
objFilesTargetDC.Close
objFilesTargetSDC.Close
Set objFSOSource = Nothing
Set objFSOTargetDC = Nothing
Set objFSOTargetSDC = Nothing
if fso.FileExists("testdeploydc.pac") then
fso.CopyFile "testdeploydc.pac", strPathDC12p & strFileTargetPath
fso.CopyFile "testdeploydc.pac", strPathDC13p & strFileTargetPath
else
wscript.echo "testdeploydc.pac does not exist"
end if
if fso.FileExists("testdeploysdc.pac") then
fso.CopyFile "testdeploysdc.pac", strPathSDC14p & strFileTargetPath
fso.CopyFile "testdeploysdc.pac", strPathSDC15p & strFileTargetPath
else
wscript.echo "testdeploysdc.pac does not exist"
end if
Set fso = Nothing
Wscript.echo "deployment finished"
If Err.Number <> 0 Then
WScript.Echo "Error: " & Err.Number & "; Description: " & Err.Description
Err.Clear
End If