dextry

Begginer help- how to export date details from when the script was last run

11 posts in this topic

#1 ·  Posted (edited)

Hello,

I am a beginner when it comes to scripting but I am learning fast. I made a script to automate SAP login for work. I made this because we have 125 SAP instances and they all have a password that expires in 1 month if the agent doesn't log in. I need a script to export date details to .txt for when it was last runned so we can tell if that SAP instance password needs to be changed soon or it can wait.

Can someone please help or give me a suggestion or a tip?

 

This is the script. I know is very basic but I am beginner.

PS: I ran the SAPLOGON application from cmd cuz it doesn't work if I just try to run it with "Run SAPLOGON.exe"

 

Thanks in advance

#include <GUIConstantsEx.au3>


Run("cmd.exe")
WinWait("C:\Windows\system32\cmd.exe")
Send("start saplogon.exe")
Send("{ENTER}")
sleep(3000)
WinClose("C:\Windows\system32\cmd.exe")
WinActivate("SAP Logon 730", 5)
ControlClick("SAP Logon 730", "", "[CLASS:Edit1]")
Send("Everest MP EP1")
Sleep(1000)
Send("{ENTER}")
WinActivate("SAP")
Sleep(2000)

$Ini = @ScriptDir& '\Username.txt'
If FileExists($Ini) Then
Local $TextIniRead1 = IniRead($Ini, "Paste", "1", "Not found")
Else
    IniWrite($Ini, "Paste", "1", 'Username')
EndIf

HotKeySet('{-}', 'Username')

Func Username()
    ConsoleWrite($TextIniRead1 & @CRLF)
    Send($TextIniRead1)

 EndFunc   ;==>Mail1


 Sleep(1000)
Send("{-}")

Sleep(2000)
Send("{TAB}")

$Ini = @ScriptDir& '\Password.txt'
If FileExists($Ini) Then
Local $TextIniRead1 = IniRead($Ini, "Paste", "1", "Not found")
Else
    IniWrite($Ini, "Paste", "1", 'Password')
EndIf

HotKeySet('{+}', 'Password')

Func Password()
    ConsoleWrite($TextIniRead1 & @CRLF)
    Send($TextIniRead1)

 EndFunc   ;==>Mail1



Send("{+}")
Sleep(1000)
Send("{ENTER}")
Sleep(1000)
WinActivate("SAP Easy Access")
Sleep(4000)
WinClose("SAP Easy Access")
Sleep(2000)
WinActivate("SAP Logon 730")
Sleep(4000)
WinClose("SAP Logon 730")

 

 

Edited by JLogan3o13

Share this post


Link to post
Share on other sites



#2 ·  Posted

@dextry your question is unclear. Does this script work for you, and you're asking on how to improve it? Or is it not working? If it is not working, please explain in detail what is happening (errors, etc.) so we can assist. We need more detail in order to help you.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#4 ·  Posted

Hello, thank you for the reply.

 

The script works with no errors. It opens SAP logs me in and then logs me out. But I have like 125 SAP instances and SAP will lock my account in any of these instances if I do not log in at least 1 per month. I don't use them all but sometime I need to use like a SAP instance very rarely used and my account is locked cuz I didn't login at least once per month for that SAP instance.

 

I wanted to know if I can add to my script something that will export the date details for when it was last runned. For Example: I run it today and it exports the date details (1/4/2017 ) in a .txt file. and next time I can see when I last  runned the script and logged in for that SAP instance so I do have to log in to all SAP instances every 1-2 weeks. Because they are 125 even if I automated all the loggings it take 50+ minutes to run script for all instances.

 

Thank you in advance. 

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

If the script is working for you as-is, why not just set it using Task Scheduler to run every ~3 weeks. That way you're not having to parse a text file to see when you logged in last.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#7 ·  Posted

4 minutes ago, JLogan3o13 said:

If the script is working for you as-is, why not just set it using Task Scheduler to run every ~3 weeks. That way you're not having to parse a text file to see when you logged in last.

Thank you for the reply. We have 40+ agent on the floor and 125 SAP instances. I will have to make a Task Scheduler for every instance on every agents machine. Let me know if you have any ideas. :D

 

Thank you in advance:D

Share this post


Link to post
Share on other sites

#8 ·  Posted

Just to clarify, you have 40 different users, on 40 different machines, who could potentially login to one of 125 SAP instances. You want to capture the instances that are not logged into within 30 days, to avoid a lockout. Does that about sum it up?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#9 ·  Posted

So yes, 40 users with 40 machines who can log in to 125 SAP Instances. and want to capture the instances that are not logged into within 30 days. I made the script for every SAP instance so they can run it and do nothing, it automatically logs them and logs out this insures that the account don't get locked. But there are to many instances and you cannot remember when was the last time you logged in to what instance in order to not get the account locked. If you have any suggestions I am listening.

 

Thanks a lot for the support!

Share this post


Link to post
Share on other sites

#10 ·  Posted

Did you create the a SAP Shortcut as per the instructions in Post#5?  If so can you open the Shortcut.sap with Notepad and send through the results?

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

nvm.

Edited by caramen

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now