VBScript

VBScript

Option Explicit

Dim ShellObj, sCathiLoc, sIniFile, sLeft, sFind, pos, boolCathiMode, boolUnicodeMode

set ShellObj = CreateObject ( " WScript.Shell " )
sCathiLoc
= EES( " %CathiDir% " )

sIniFile
= FileToString(sCathiLoc + " \BindingOutForBug193413.xml " )

' Replace the host name of Microsoft.Test.Ebiz.OpsMan.Scenarios.EquityLoan.EquityLoanOrchestration to none
sFind = " <Host Name=""BizTalkServerApplication"" NTGroupName=""BizTalk Application Users"" Type=""1"" Trusted=""true"" /> "
pos
= InstrRev (sIniFile, sFind)
sLeft
= Left (sIniFile, pos - 1 )
sIniFile
= Replace (sIniFile, sFind, " <Host xsi:nil=""true"" /> " , pos - 1 , 1 )
sIniFile
= sLeft + sIniFile

Call StringToFile(sIniFile, sCathiLoc + " \BindingInForBug193413.xml " )

' ************************************************************
'
Utility function to get a enviroment location
'
************************************************************
Function EES(EnvVar)
EES
= ShellObj.ExpandEnvironmentStrings(EnvVar)
End Function

' ************************************************************
'
Utility function to read a file into a string
'
************************************************************
Function FileToString(sPath)
Dim fso, f
Const ForReading = 1
Const TristateTrue = - 1

Set fso = CreateObject ( " Scripting.FileSystemObject " )
if fso.FileExists(sPath) = 0 then
if not boolCathiMode then
wscript.echo
" Input file doesn't exist: ' " & sPath & " ' "
else
Call objLog.LogFail( CStr ( " Input file doesn't exist: ' " & sPath & " ' " ))
end if
WScript.Quit(
1 )
end if

if boolUnicodeMode then
Set f = fso.OpenTextFile(sPath, ForReading, false , TristateTrue)
else
Set f = fso.OpenTextFile(sPath, ForReading)
end if

FileToString
= f.ReadAll
f.Close

Set f = Nothing
Set fso = Nothing
end Function

' ************************************************************
'
Utility function to write a string to a file
'
************************************************************
Sub StringToFile(sString, sPath)
Dim fso, f, hHandle

Set fso = CreateObject ( " Scripting.FileSystemObject " )
if boolUnicodeMode then
Set f = fso.CreateTextFile(sPath, true , true )
else
Set f = fso.CreateTextFile(sPath, true )
end if

f.Write sString
f.Close

if Err.number <> 0 then
PrintWMIErrorthenExit Err.Description, Err.Number
else
if not boolCathiMode then
wscript.echo
" Output file is created: ' " & sPath & " ' "
else
Call objLog.LogInfo( CStr ( " Output file is created: ' " & sPath & " ' " ))
end if
end if

Set f = Nothing
Set fso = Nothing
end Sub

 

 

 

-----------参考网站------------ 

http://en.wikipedia.org/wiki/VBScript

Wiki

http://www.w3school.com.cn/vbscript/index.asp

VBScript教程@W3School

http://msdn.microsoft.com/en-us/library/k9z80300(v=VS.85).aspx

Replace Method (VBScript)@MSDN

http://msdn.microsoft.com/en-us/library/hsxyczeb(v=VS.85).aspx

InStrRev Function@MSDN

http://forum.openvpn.eu/viewtopic.php?f=25&t=7266&start=0

Example of ShellObj.ExpandEnvironmentStrings

转载于:https://www.cnblogs.com/pegasus923/p/1879466.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值