Skip to Content
Author's profile photo Dharmesh Kumar

SAP Automatic Logon using BAT file

Hi,

After GUI 740, it is not possible to have password field enabled in SAP shortcut so passwords cannot be saved. The reg values doesn’t create if you run “sapshcut.exe -register”. I also tried inserting “EnablePassword” string value manually in registry, but no luck.
So after little research I came with this another approach of automatic SAP login using batch files. But please be aware that login information is stored in a BAT file which is not encrypted and can be used to gain unauthorized access.


In my case, I have 3 clients for one SAP system,  one client is for development and 2 for Unit testing. Because of this such landscape, I could not use GuiXT effectively so I found this way of using batch file much better for such scenarios.

Steps

1. Create a folder where you want to store all login files (batch file).
2. In that folder, create a text file and put this code into it

start sapshcut -sysname=xxx -client=xxx -user=xxxxxx -pw=xxxxxxxx

sysname = system ID in logon pad
pw = password

(more info on parameters can be found on run –> sapshcut.exe /? )

3. Once done, save this file and change file name to <SYSID_CLIENT>.BAT and change save as type to ‘all files(*)’.

4. We are done !!!.. just double click on the batch file and no need to remember any system details from now on 🙂

Regards
Dharmesh

Assigned Tags

      18 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Matt Fraser
      Matt Fraser

      Hi Dharmesh,

      Can you describe how this would compare against the method detailed in https://blogs.sap.com/2016/10/31/save-password-sap-logon-shortcut/ (published just yesterday -- why does everyone suddenly want to save passwords in shortcuts?)? Also, as was pointed out in that other blog, this saving of passwords on your PC is not generally considered a good idea.

      Cheers,

      Matt

       

      Author's profile photo Dharmesh Kumar
      Dharmesh Kumar
      Blog Post Author

      Hi Matt,

      The blog you mentioned is about the standard SAP functionality of logging into SAP system directly using shortcut. I found it the best way of automatic logging before 740 final release.
      By default, the password field in shortcut use to be disabled by SAP which needs to be enabled to allow password input using "sapshcut.exe -register" which inserts required registery values.

      After 740 release, it is not allowed to enter password in shortcuts at all (even if you insert these keys manually). In my case we have 20 SAP systems and most of them have 2-3 clients. It becomes very hard to remember all these passwords and if entered incorrectly, it takes 2-3 hours to get it unlocked, So my method is simply to create .bat file, call sapshcut.exe and provide password at runtime.

      I do understand that it is not the best idea as saving passwords in plain batch file is of security concern. But as my PC is not shared and I can save the files locally, there is no way it can be misused. Depending on scenarios, you can take extra measures to protect your batch files.

      Regards
      Dharmesh

      Author's profile photo Matt Fraser
      Matt Fraser

      The blog is specifically addressing how to save passwords in shortcuts using SAPGUI 7.40 after patch 1, and as talked about in Note 146173. Yes, it's still not recommended, but at least in this circumstance the password is not saved in cleartext. I would think that this would meet your requirement. As a system administrator of numerous systems myself, I certainly understand the frustration of trying to remember lots of different passwords.
       

      Author's profile photo Former Member
      Former Member

      Hi Dharmesh,

      Thanks for this blog, looks interesting.

      I can suggest you one more idea.

      Please use KeePass Tool(you can download from Google) , Easy to use,  It keeps your password

      safe and secured. Just Click and your SAP system will be login automatically.

      Regards,
      Sujoy

      Author's profile photo Dharmesh Kumar
      Dharmesh Kumar
      Blog Post Author

      Hi Sujoy,
      Thanks for the suggestion. Unfortunately, we do not have authority to install softwares but creating batch files is open for all 😉

      Regards
      Dharmesh 

      Author's profile photo Mathew SANDERSON
      Mathew SANDERSON

      Hello Dharmesh,

      Use the portable version of KeePass and you do not have to install the software.

      If you can connect a USB flash drive, then simply put KeePass on the flash drive and run it from there.

      The portable version is available from the offical KeePass website.

      Regards

      Author's profile photo YUNUS KALDIRIM
      YUNUS KALDIRIM

      Hi Dmarmesh,

      You can follow below steps. It's totaly for you and whom searching store password
      https://blogs.sap.com/2016/10/22/use-sap-shortcut-password-gui-7.40-nwbc/

      Author's profile photo Dharmesh Kumar
      Dharmesh Kumar
      Blog Post Author

      Hi Yunus,

      The link isn't working.

      Regards
      Dharmesh 

      Author's profile photo Frank Krause
      Frank Krause

      Hi all,

      I would like to stress again the SAP view on the "saving passwords in SAP Shortcuts" feature.

      1) Using this feature is a security risk. In the interest of all users we strongly have to mention again that it should not be used. This holds true especially if users are not aware of the fact that an SAP Shortcut with full credentials in it can be used by anybody to log on with a foreign user account. Yes, you may say that you protect the files on your hard disk, but will all users do this (or will they even mail the shortcuts)? From SAP perspective this risk should not be ignored and therefore the administrators should NOT enable the feature.

      2) There are better and more secure alternatives to the feature available (SSO solutions); if it is just about remembering passwords there are many programs available which store passwords in a safe way.

      3) The password saving feature does not have a future anymore. With the introduction of SAP UI Landscape it has been removed and even though it is still working for saplogon.ini it is just a question of time until SAP GUI for Windows will no longer support saplogon.ini at all (before you ask: SAP GUI for Windows 7.50 will still support saplogon.ini). This feature will thus disappear.

      4) SAP UI Landscape is already in release 7.40 mandatory for the combined usage of SAP GUI for Windows and the SAP Business Client. If you turn off SAP UI Landscape you cannot run this combination which adds a lot of value for end users.

      My summary is therefore: Don't use this feature!

      Best regards,
      Frank

       

      Author's profile photo YUNUS KALDIRIM
      YUNUS KALDIRIM

      Hi,
      Thanks for everyone about security risk suggestions. NWBC is not well produced compared to SAPGUI. Maybe it will be better in the future.  Beside this SAP removed my suggestion blog for continue password saving in saplogon and i put it in my homepage. You can find solution in this link.

      http://www.ykburda.com/2016/11/how-to-use-sap-shortcut-password-with-gui-7-40-with-nwbc/

      Author's profile photo Ashok Kumar
      Ashok Kumar

      Hi All,

      I am new to SAP.I tried automating the SAP login,selecting the database and providing the TCODE using batch script. But i am unable to provide table name,run the table and export the data.

      Can anyone of you help .

      Thanks in advance.

      Script i have written:

      @echo off
      cd \
      set /p Username= Enter username:
      set /p Password= Enter password:
      set /p Tcode= Enter Tcode:
      set /p Database=Enter Database:
      REM: cd Program Files\SAP\FrontEnd\SapGui
      start sapshcut.exe -system=%Database% -client=320 -command=%Tcode% -user=%Username% -pw=%Password%
      pause

      Thanks,

      Ashok

      Author's profile photo S. Dickie
      S. Dickie

      Hi all, i have amended the instructions above to log on using SNC/SSO. However, my 'regular' saplogon.exe no longer works.

       

      Is it possible to have .bat and .exe options working?

      Author's profile photo Anil reddy
      Anil reddy

      Hi @Dharmesh Kumar,

      When using the .bat files to access my SAP systems, I'm unable to use SAP LogOn pad in case if I need to add new system or if I want to check the existing systems.

      Any idea on this?

       

      Regards,

      Anil

      Author's profile photo Dharmesh Kumar
      Dharmesh Kumar
      Blog Post Author

      Hi Anil,

      I tried to edit my logon pad entries while using .bat file but I didn't face such issue and was able to create new entries or edit any existing entry.

      You might need to use some other shortcut parameter if it could help.

      SAP%20GUI%20Shortcut%20parameters

      SAP GUI Shortcut parameters

      Author's profile photo Anil reddy
      Anil reddy

      Thank you Dharmesh for your quick response.

      Not sure what's wrong, but I'm unable to open LogOn pad.

      The script which I used is given below. Could you please confirm anything wrong.

      "start sapshcut -system=SID -client=000 -user=USERNAME -pw=PASSWORD -maxgui -language=E"

      Though it is very simple script, but can't open LogOn pad.

      Regards,

      Anil

      Author's profile photo Dharmesh Kumar
      Dharmesh Kumar
      Blog Post Author

      No mate, I don't see any problem in the script.

      Maybe searching on other forums can help.

       

      Regards,

      Dharmesh

      Author's profile photo Anil reddy
      Anil reddy

      Thanks again for your prompt reply Dharmesh.

      I'll check somewhere.

      Regards,

      Anil

      Author's profile photo Ankit Kulkarni
      Ankit Kulkarni

      Hi Anil,

      Replace system with sysname and run the script. It will work.

       

      Regards,

      Ankit