on 2019 Apr 01 7:20 AM
I have difficulty using the xp_cmdshell to start an .exe file or a .batch file, which starts an exe, which in turns is a desktop application connecting to the database. so, from dbisql I write xp_cmdshell 'C:\\temp\\startreports.bat' Actually I have this problem only when I start the DBSRV10 from within a service (dbsvc).
Our startreports.exe is on environment and registry dependant, so that I start the service with a specific user (which has an appropriate profile for the exe) so it looks something like:
dbsvc -a WIN_USER -p WIN_PWD -s Manual -sd "SOME_DESCRIPTION" -t network -w SVC_NAME "C:\\Program Files (x86)\\SQL Anywhere 10\\win32\\dbsrv10.exe" -xs http(port=8888) -n SRV_NAME -c 768M "C:\\TEST\\DB1.db"
I dont see any other possibility to change the service (could the -i change something) (-i = allow service to interact with desktop), but I had always difficulty to add this option to the dbsvc!!
Request clarification before answering.
So far we have tried to explain the problem. If you really need a SQL Anywhere server running as a service to display a GUI, you will need some kind of "man in the middle" in my understanding. That is because a service uses an invisible "window station" whereas a visible GUI must be run within the one and only "interactive window station".
Let's use a very silly example: Say, your SQL Anywhere server service would do regular backups of its database but want to ask the user to confirm that. Therefore it would need to display a simple message box awaiting a "yes" or "no" answer.
AFAIK, you would need a process running in the session of the logged-in interactive user (say, automatically started via "AutoStart"). That process would be silently waiting for an event triggered by the database service. One means would be to check for modified database contents but I would prefer a basic OS IPC facility like a named Win32 event. So that "waiter" would just use one of the Win32 wait functions to wait on the event to be set.
When the database server wants to ask for a backup, it would "do something" to signal that event. That's (rather easily) doable via an external C function that maintains and sets the according event. (FWIW, that's something we use ourselves to synchronize processes - for different reasons, apparently...). So some database code calls that external function which in turn sets the event. (Alternatively, you could use xp_cmdshell to call an application that sets such an event.)
Now the "waiter" process in the interactive session is notified that the event is set and therefore displays the GUI, either as part of its own process or by starting a GUI app. As the "waiter" runs within the interactive window station, its output and that of processes it has started are visible for the logged-in user. So a message box is displayed, and the user chooses "yes" or "no".
In this sample, the database service needs to get the GUI's result. So there must be another IPC in the opposite direction: The database code would need to wait for the response, either by waiting for some database modification (say, the GUI would change a database row based on the user's input) and/or by another event set by the "waiter" that the GUI has closed. As a consequence, the database server would now do a backup or skip that task. (As stated, it's a silly sample...:)).
The waiter would reset the first event and would return to its "waitning" state and wait until the database server sets that event again.
I have not used code like that to make a SQL Anywhere service display a GUI, however we have used IPC to synchronize tasks within SQL Anywhere with other processes for years, and that has worked fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
an interesting alternative is the SYSTEM statement, which can start an GUI from within DBISQL even if the DB is started as Service. The drawback is that this statement can only be used within dbisql, and can not be called within a procedure.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
New to me too, and embarrassing... because it dates back to V5.5 at least:
User's Guide Part VI. SQL Anywhere Reference Chapter 43. Watcom-SQL Statements SYSTEM statement Function To execute an operating system command from within ISQL. Syntax SYSTEM [ operating-system-command ] Usage ISQL (DOS and QNX only).
User | Count |
---|---|
39 | |
15 | |
9 | |
7 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.