WINDOWS指令碼實踐:為SAP補丁製作的VBS指令碼代碼

來源:互聯網
上載者:User

指令碼主要功能包括:

註冊表讀取與修改
檔案內容修改如HOSTS、SERVICES檔案
檔案屬性修改和檔案複製
系統內容變數設定
等,僅供參考

複製代碼 代碼如下:'SAP設定指令碼
'編寫:SCZ 2005.04.20
'最後修改日期: 2005.04.22
'必須存在目錄: BW(補丁檔案) 和 登入介面
'========================================================================
'全域變數、處理過程
'========================================================================
WScript.Echo "該指令碼只能正常運行在WIN2000/XP/2003的作業系統管理員權限下,按'確定'繼續"
Set objFSO = CreateObject("Scripting.FileSystemObject") '檔案系統對象
strWindir = GetWindir() '擷取WINDOWS目錄
strSystem = GetSystemPath() '擷取System目錄
strSapPath = GetSAPPath() 'SAP FrontEnd目錄
strSapGuiPath = strSapPath & "SAPgui" 'SapGui目錄
strSapBWPath = strSapPath & "BW" 'BW目錄
strHostPath = GetHostFilePath() 'host 檔案所在目錄
strServicesPath = GetServicesPath() 'services 檔案所在目錄

Call CopyFiles() '複製檔案
Call ModifyHost(strHostPath) '修改HOST檔案
Call ModifyServices(strServicesPath) '修改SERVICES檔案
Call SetEvn(strSapGuiPath) '設定環境變數
Call SetTCPIP(strServicesPath) '修改TCPIP參數
WScript.Echo "BW設定處理完畢,請手動安裝SAP系統補丁"

'========================================================================
'通過註冊擷取SAP FrontEnd目錄
'========================================================================
Function GetSAPPath()
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\" & _
strComputer & " ootdefault:StdRegProv")

strKeyPath = "SOFTWARESAPSAP Shared"
strEntryName = "SAPdestdir"
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strEntryName,strValue
GetSAPPath = strValue
If IsNull(strValue) Then
Wscript.Echo "SAP註冊資訊讀取失敗,SAP未安裝或系統已損壞,安裝終止"
Err.Raise(507)
Err.Clear
End If
End Function

'========================================================================
'擷取WINDOWS目錄
'========================================================================
Function GetWindir()
Const WindowFolder = 0
Set GetWindir = objFSO.GetSpecialFolder(WindowFolder)
End Function

'========================================================================
'擷取SYSTEM目錄
'========================================================================
Function GetSystemPath()
Const SystemFolder = 1
Set GetSystemPath = objFSO.GetSpecialFolder(SystemFolder)
End Function

'========================================================================
'擷取HOST檔案所在目錄
'========================================================================
Function GetHostFilePath()
GetHostFilePath = strSystem & "driversetc"
End Function

'========================================================================
'擷取Services檔案所在目錄
'========================================================================
Function GetServicesPath()
GetServicesPath = strSystem & "driversetc"
End Function

'========================================================================
'複製檔案
'========================================================================
Function CopyFiles()
If NOT objFSO.FolderExists(strSapBWPath) Then
WScript.Echo "BW組件未安裝,請先安裝SAP的BW組件,再運行該指令碼"
Err.Raise(507)
Err.Clear
End If

Call ClearAttribs(strSapBWPath)

objFSO.CopyFile "登陸介面*.ini" , strWindir
objFSO.CopyFile "BWgssntlm.dll" , strSapGuiPath & "gssntlm.dll"
objFSO.CopyFile "BWsncgss32.dll" , strSystem & "sncgss32.dll"

strBakFolder =strSapBWPath & "

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.