#-Begin-----------------------------------------------------------------
$Sig = @'
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
'@
#-Add FindWindow function---------------------------------------------
$Win32 = Add-Type -Namespace Win32 -Name Funcs -MemberDefinition $Sig -PassThru
#-Set the path to the SAP GUI directory-------------------------------
$SAPGUIPath = "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\"
#-Set the SAP system ID or the IP address-----------------------------
$SID = "NSP"
#-Set the instance number of the SAP system---------------------------
$InstanceNo = "00"
#-Starts the SAP GUI--------------------------------------------------
$SAPGUI = $SAPGUIPath + "sapgui.exe"
& $SAPGUI $SID $InstanceNo
While ($Win32::FindWindow("SAP_FRONTEND_SESSION", "SAP") -eq 0) {
Start-Sleep -Milliseconds 250
}
Write-Host "Here now your script..."
#-End-------------------------------------------------------------------
#-Begin-----------------------------------------------------------------
#-Includes------------------------------------------------------------
."COM.ps1"
#-Signatures----------------------------------------------------------
$Sig = @'
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
'@
#-Add FindWindow function---------------------------------------------
$Win32 = Add-Type -Namespace Win32 -Name Funcs -MemberDefinition $Sig -PassThru
#-Set the path to the SAP GUI directory-------------------------------
$SAPGUIPath = "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\"
#-Set the SAP system ID-----------------------------------------------
$SID = "localhost"
#-Set the instance number of the SAP system---------------------------
$InstanceNo = "00"
#-Start the SAP GUI---------------------------------------------------
$SAPGUI = $SAPGUIPath + "sapgui.exe"
& $SAPGUI $SID $InstanceNo
#-Wait until the session is available---------------------------------
While ($Win32::FindWindow("SAP_FRONTEND_SESSION", "SAP") -eq 0) {
Start-Sleep -Milliseconds 250
}
#-Logon to SAP GUI session--------------------------------------------
$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-------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
5 | |
5 | |
4 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 |