I automated our SAP system using SAP Gui Scripting. After 30 minutes where the script works, our SAP system logs off (auto-logoff) because it doesn't recognize the activities of the script. Is there a parameter to change this?
Don't missunterstand me - I don't want to deactivate auto logoff. I want SAP to recognize the script activities so auto logoff woulnd't be performed as long as my script is working.
Regards and thank you,
Jan
For me, for this reason, the following script runs automatically the whole day after logging in:
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set application = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(connection) Then
Set connection = application.Children(0)
End If
If Not IsObject(session) Then
Set session = connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject application, "on"
End If
wscript.sleep 2000
do
'if time() > "16:00" then exit do
on error resume next
session.findById("wnd[0]").maximize
if err.number <> 0 then exit do
on error goto 0
session.findById("wnd[0]/tbar[0]/okcd").text = "/o"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").close
wscript.sleep 29000
Loop
Regards,
ScriptMan
Related
Ive created a server monitoring script written in classic ASP (Hosted on IIS 7.5).
It has a main page which uses jQuery to automatically reload the content (updating WMI information) It works great, but seems to have an appetite for memory!
There are 4 pages (Service status for 2 servers, printer status on a main DC and disk usage on the same server) The service status pages update every 10 seconds, the printers every 5 seconds and disk usage every minute.
The script basically works for a few hours, then i get code 500 internal server errors, once checking the IIS logs its because of it being "Out of memory" and look at the processes on the server and WmiPrvSvc.exe (NETWORK SERVICE account) is in the hundreds (500mb) and the ISS worker process (w3wp.exe) is using about 50mb (there are other w3ps.exe processes that are higher)
Once i end them both it kicks back into action… Or if i stop the page/requests for a while (varies between 30 sec and 5 mins) the WmiPrvScs ends and i don't get the problem.
Is there a way to minimise the memory usage or is there a command to properly disconnect / clear the memory?
Below is the basics of one of my pages to give you an idea of what's going on...
Thanks, Paul.
<%
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("SELECT Caption, Started FROM Win32_Service WHERE StartMode = 'Auto'")
Set arrServices = Server.CreateObject("System.Collections.ArrayList")
intServices = colListOfServices.Count
For Each objService in colListOfServices
arrServices.Add objService.Caption & "#" & objService.Started
Next
arrServices.Sort()
Response.Write "<table width=""100%"" class=""tblServices"">" & vbCr
For Each strService in arrServices
If InStr(strService, ".NET Framework") = 0 AND InStr(strService, "Sophos Web Intelligence Update") = 0 AND InStr(strService, "Shell Hardware Detection") = 0 Then
' Above services, start at system startup and then stop after nothing to do
arrServiceDetails = Split(strService, "#")
strServiceName = arrServiceDetails(0)
strServiceStatus = arrServiceDetails(1)
End If
Next
Response.Write "</table>"
Set objWMIService = Nothing
Set colListOfServices = Nothing
Set arrServices = Nothing
%>
Are you calling the above code every 10 seconds?
I´m not sure, but i looks like you are creating a new WMI object / connection everytime and that adds up.
Instead try to keep the object around instead of recreating it. Something like a SingleTon class to hold the connection.
Also, try making a strongly typed class instead of the WMI query, you can do that by looking at this site: MGMTClassGen
I've made a rule in Outlook VB
Sub Test(Item As Outlook.MailItem)
Dim message
message = Split(Item.Body, vbCrLf)
...
End Sub
However, anytime it runs I get this message:
I'm fairly certain this is coming from Item.Body, and I can silence this alert for up to 10 minutes, but I would rather just turn it off entirely.
Is this possible? If not is there a way I can extend the timer past 10 minutes?
This is relating to Outlook 2003 on Windows XP.
You can turn this off by creating\setting the value of CheckAdminSettingsto 1 in the Registry Key HKEY_CURRENT_USER\Software\Policies\Microsoft\Security
see MS Article and MS Article
I've a classic ASP page which call a en external webservice.
this is how the actual process works:
'[Part0 : Call the external webservice]
wsResponse = setConfirmation(...)
' [PART1: external webservice is responding]
if not wsResponse is Nothing then
'....Process the response from the webservice according to wsResponse
code =wsResponse.getCode
if code = 'C' then
'We confirm the transaction and call a storedprocedure in SqlServer
else
'if code is different from C, we assume, the transaction status is 'not confirmed' or 'cancelled'
'[PART2: no answer from external webservice]
Else
'so wsReponse is nothing..We don't get any answer from the external webservice
'transaction is not confirmed
'the transaction status is set to 'not confirmed' in database
So what I want to do is that in PART2 (when no answer is get from external webservice), wait 30 seconds before send 'not confirmed' status in database . So I will like to do PART0 again ie: Call again the external webservice at least 10 times and see if it responding or not. A kind of recursive process.
So I was thinking of 2 way of doing this:
In PART2, put ASP to sleep for 30s and to PART0 again (Call the webservice) and if still no response, write in DB, transaction not confirmed, but if response, then do PART1.
In PART2, Call repeat PART0 at least 10 times, if after 10 trials, there is no response, then write in DB, transaction is not confirmed.
So my question is: is there a better way to do this or which or 1 or 2 will be better? and also, for 1, how can we put ASP to sleep like in dotnet or PHP?
Thanks for your answers.
Regards
Here is a simple subroutine that will delay for as many seconds as you need
Sub MyDelay(NumberOfSeconds)
Dim DateTimeResume
DateTimeResume= DateAdd("s", NumberOfSeconds, Now())
Do Until (Now() > DateTimeResume)
Loop
End Sub
Just call this subroutine in Part 2
Call MyDelay(30)
I don't know any way to put ASP to sleep. Especially when you are on a hosted web. So what I would do is this: I would have a service like Pingdom.com to request an ASP page every say 10 seconds. The requested ASP page will then attend to any pending transactions (logged in a tabel).
I have a requirement when a user clicks a specific arrangement of radio buttons to run a series of vbscripts (and soon Perl scripts).
I have all of the vbscripts stored server side, they do not need to be on the remote system to run. Oh yes, the scripts are gathering information on remote system in our intranet.
What would be the best way. Currently I have this to run just one script, not multiple...should I keep this or dispose of this idea.
Protected Sub windowsScript(ByVal COMPUTERNAME As String)
' Create an array to store VBScript results
Dim winVariables(1) As String
Dim filePath As String = COMPUTERNAME & "\C$\Windows\somefile.txt"
'Execute PsExec on script
runPsExec(COMPUTERNAME, "systemInfo.vbs", 1)
'Import data from text file into variables
textRead(filePath, winVariables)
System.Threading.Thread.Sleep(1000)
'Delete the file on server - we don't need it anymore
runPsExec(COMPUTERNAME, "systemInfo.vbs", 2)
MsgBox("Windows OS: " & winVariables(0).ToString())
MsgBox("Service Pack: " & winVariables(1).ToString())
End Sub
Also, it is hard to see here because I do have another function "textRead" but what is going on is this particular script is stored client side and the vbscript it outputting to a text file. textRead will read the variable and send a text file back to the server to read it.
This is definitely not what I want to do.
I want to be a little more dynamic, plus with my new scripts...they don't need to be on the client at all.
Any help would be appreciated :)
I'm thinking of making some type of While loop, not sure if that would work.
It's kind of strange to do this through the browser. In my company we collect systeminfo at logontime with a vbscript logonscript and add the result to a logfile which we can access through a webapp to do research. Occasionally when the need rises we run a specific script to gather more data or change some system setting through windows SCCM.
If the goal is to provide the user with info about his system there are some good utilities around which can be run locally (but from a location on a server share).
EDIT
a simple way to start multiple processes
dim scripts_to_run, script
const COMPUTERNAME = 0, SCRIPTNAME = 1, EXTRA_PARAMS = 2
scripts_to_run = Array(_
Array("computer1","script1.vbs",1),_
Array("computer2","script1.vbs",0),_
Array("computer3","script3.vbs",3)_
)
for each script in scripts_to_run
runPsExec script(COMPUTERNAME), script(SCRIPTNAME), script(EXTRA_PARAMS)
runPsExec join(script,",")
next
sub runPsExec(p1, p2, p3)
'here coms your code shat runs the script
wscript.echo p1 & p2 & p3
end sub
or a shorter version
dim scripts_to_run, aArgs
scripts_to_run = Array(_
Array("computer1","script1.vbs",1),_
Array("computer2","script1.vbs",0),_
Array("computer3","script3.vbs",3)_
)
for each aArgs in scripts_to_run
runPsExec aArgs
next
sub runPsExec(aArgs)
'here coms your code shat runs the script
wscript.echo aArgs(0) & aArgs(1) & aArgs(2)
end sub
I am running a database transaction using ADO and VBScript in a classic ASP page, that involves multiple calls to Execute method of connection object (i.e. conn.Execute) .
I have found that I need to set 'On Error Resume Next' at the top of my page, so that when any of the transaction calls ( i.e. conn.Execute ) fails, then I can follow it with roll back code.
Can I run an ADO transaction, even when the error mode is 'On Error GoTo 0' rather than 'On Error Resume Next' in my classic ASP page? Sample code for rolling back transaction is as below.
'Rollback transaction if a previous conn.Execute fails
if err.Number <> 0 then
if tranCount = 1 then
conn.RollbackTran
tranCount = 0
end if
end if
Interesting question!
I usually don't do database transactions from classic ASP so Im not sure that conn.Errors will trap errors before the ASP-script. But you can at least try...
IF conn.Errors.Count > 0 THEN
response.write "whoops"
END IF
Otherwise it might help you to know that On Error Resume Next is effective only in the current scope. (see code below)
<%
response.write "start"
BadFunction()
response.write "middle" '//<--- This will be printed
dim b : b = 8 / 0 '//Division by zero
response.write "end" '//<-- This will NOT be printed!
Function BadFunction()
On Error Resume Next
dim a : a = 9 / 0 '//Division by zero
BadFunction = a
End function
%>