
#-Begin-----------------------------------------------------------------
#-Get-Property--------------------------------------------------------
function Get-Property {
param([__ComObject] $object, [String] $propertyName)
$objectType = [System.Type]::GetType($object)
$objectType.InvokeMember($propertyName,
"GetProperty", $NULL, $object, $NULL)
}
#-Set-Property--------------------------------------------------------
function Set-Property {
param([__ComObject] $object, [String] $propertyName,
$propertyValue)
$objectType = [System.Type]::GetType($object)
[Void] $objectType.InvokeMember($propertyName,
"SetProperty", $NULL, $object, $propertyValue)
}
#-Invoke-Method-------------------------------------------------------
function Invoke-Method {
param([__ComObject] $object, [String] $methodName,
$methodParameters)
$objectType = [System.Type]::GetType($object)
$output = $objectType.InvokeMember($methodName,
"InvokeMethod", $NULL, $object, $methodParameters)
if ( $output ) { $output }
}
#-Main----------------------------------------------------------------
$SapGuiAuto = [microsoft.visualbasic.Interaction]::GetObject("SAPGUI")
$application = Invoke-Method $SapGuiAuto "GetScriptingEngine"
$connection = Get-Property $application "Children" @(0)
$session = Get-Property $connection "Children" @(0)
$ID = Invoke-Method $session "findById" @("wnd[0]/usr/txtRSYST-MANDT")
Set-Property $ID "Text" @("001")
$ID = Invoke-Method $session "findById" @("wnd[0]/usr/txtRSYST-BNAME")
Set-Property $ID "Text" @("BCUSER")
$ID = Invoke-Method $session "findById" @("wnd[0]/usr/pwdRSYST-BCODE")
Set-Property $ID "Text" @("minisap")
$ID = Invoke-Method $session "findById" @("wnd[0]/usr/txtRSYST-LANGU")
Set-Property $ID "Text" @("EN")
$ID = Invoke-Method $session "findById" @("wnd[0]")
Invoke-Method $ID "sendVKey" @(0)
#-End-------------------------------------------------------------------
#-Begin-----------------------------------------------------------------
$VB = New-Object -COMObject MSScriptControl.ScriptControl
$Cmd = @"
Set SapGuiAuto = GetObject(`"SAPGUI`")`n
Set application = SapGuiAuto.GetScriptingEngine`n
Set connection = application.Children(0)`n
Set session = connection.Children(0)`n
session.findById(`"wnd[0]/usr/txtRSYST-MANDT`").text = `"001`"`n
session.findById(`"wnd[0]/usr/txtRSYST-BNAME`").text = `"BCUSER`"`n
session.findById(`"wnd[0]/usr/pwdRSYST-BCODE`").text = `"minisap`"`n
session.findById(`"wnd[0]/usr/txtRSYST-LANGU`").text = `"EN`"`n
session.findById(`"wnd[0]`").sendVKey 0`n
"@
$VB.Language = "VBScript"
$VB.AllowUI = $TRUE
$VB.ExecuteStatement($Cmd)
#-End-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
7 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |