sicoobcooplivre Posted October 16, 2023 Share Posted October 16, 2023 @Sherzod Please, I would like to know if it is possible or not, and if it is the right way to do it: I have a server running an application. I would like to give a user the option on the network, to be able to access the application service via the page and to be able to restart the application, in case for some reason that I have not thought of or an error occurs in the application and it gets stuck! I wanted to do this, instead of the user having to log into the server. Is there a way to do this? Thank you for your attention! Quote Link to comment Share on other sites More sharing options...
Daniel_Davila Posted October 16, 2023 Share Posted October 16, 2023 É só você acessar o /server da tua aplicação. http://localhost:8077/MyApp/MyApp.dll/Server voce cria os usuários pelo arquivo .cfg que fica junto do IIS. English: "You need to grant access via the "/server" link of your application. http://localhost:8077/MyApp/MyApp.dll/Server Users are created through the .cfg file located alongside the IIS." Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted October 16, 2023 Author Share Posted October 16, 2023 My application is windows service! And when accessing /server , I only found the "shutdown server" option, but I can't test it, as it appears disabled! Thank you for your attention! @SherzodCould you guide me on the right way to do it, please? Thanks! Quote Link to comment Share on other sites More sharing options...
irigsoft Posted October 17, 2023 Share Posted October 17, 2023 9 hours ago, sicoobcooplivre said: My application is windows service! And when accessing /server , I only found the "shutdown server" option, but I can't test it, as it appears disabled! Thank you for your attention! @SherzodCould you guide me on the right way to do it, please? Thanks! Hello. You can use Ajax to start procedure on server and this procedure to restart app procedure uniServerModule.RestartApp; var FullProgPath: PChar; begin FullProgPath := PChar(Application.ExeName);// + ' ' + ParamStr(1)); {repeat R := MsgWaitForMultipleObjects(EventCount, EventArray, False, INFINITE, QS_ALLINPUT); if R = WAIT_OBJECT_0 + EventCount then begin while PeekMessage(M, 0, 0, 0, PM_REMOVE) do begin if M.Message = WM_QUIT then Break; TranslateMessage(M); DispatchMessage(M); end; if M.Message = WM_QUIT then Break; end; until Terminated; } //uniApplication.Terminate; UniServerModule.Terminated := True; //UniServerInstance.TerminateStandAlone(); UniApplication.Terminate('Restart Server'); // to put the app in a closed state in the browser //Application.Terminate; //WinExec (FullProgPath, SW_SHOW); //ExitProcess(0); //repeat PostThreadMessage(Application.Handle {MainThreadID},wm_quit,0,0); // will tell the main application to terminate //until Application.Terminated; Application.ProcessMessages; //PlaySystemSound (3,300,100); //PlaySystemSound (3,800,120); WinExec (FullProgPath, SW_SHOW); end; Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted October 17, 2023 Author Share Posted October 17, 2023 Good morning! Thanks for returning! In this code, does it stop and start the same application again, ending all sessions? I haven't tested it yet, I'll test it now! One question, wouldn't it be ideal for me to have a separate application just to close and start the application I need? I'm asking these questions to understand better and do it in the best way! Thank you very much for your attention! @SherzodCould you give your suggestion, please? Quote Link to comment Share on other sites More sharing options...
irigsoft Posted October 17, 2023 Share Posted October 17, 2023 50 minutes ago, sicoobcooplivre said: Good morning! Thanks for returning! In this code, does it stop and start the same application again, ending all sessions? I haven't tested it yet, I'll test it now! One question, wouldn't it be ideal for me to have a separate application just to close and start the application I need? I'm asking these questions to understand better and do it in the best way! Thank you very much for your attention! @SherzodCould you give your suggestion, please? this procedure get own thread ID and close it. So this restart application as Stand alone app. Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted October 17, 2023 Author Share Posted October 17, 2023 Okay, I'll test it! And this "shutdown server" option, is there no way to leave it active? Was it supposed to have the same function as restarting the application? Thanks! Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted October 18, 2023 Author Share Posted October 18, 2023 @SherzodCan you help, please? Quote Link to comment Share on other sites More sharing options...
Ron Posted October 20, 2023 Share Posted October 20, 2023 You could have a batch file, e.g. "restart.bat", which restarts the service: net stop uniguiService net start uniguiService The batch file may be executed in a click event handler, or you could use an incoming email or an SMS from a specific phone number, with a code word in the text, triggering a PHP file on a webserver. Using SMS, you specify which file to run at incoming messages to the the virtual SMS number, at the provider. The following PHP extracts message data from the HTTP Post call from the provider and runs the batch file, this assumes you have a running webserver set up with PHP to handle incoming calls: <?php $Sid = $_POST['MessageSid']; $From = $_POST['From']; $To = $_POST['To']; $Body = $_POST['Body']; $From = substr($From,3,8); if(($From==='12345678')&&(strtolower ($Body)==='restart')){ $output = shell_exec('c:\restart.bat'); $message = "Web Server Restart: " . $output; $response = '<?xml version="1.0" encoding="UTF-8"?><Response><Message>' . $message . '</Message></Response>'; echo $response; } ?> Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted October 23, 2023 Author Share Posted October 23, 2023 Very interesting. I'm going to study! Now talking about stopping/starting my application: sometimes when I restart my application, there are enough users logged in and it takes a while to stop. How could I do it so that when giving the "net stop" it waits for the application to actually finish, and then starts? Thanks! Quote Link to comment Share on other sites More sharing options...
Ron Posted October 23, 2023 Share Posted October 23, 2023 Quote How could I do it so that when giving the "net stop" it waits for the application to actually finish, and then starts? If you have both the start and stop commands in the batch file, as mentioned, it will wait for the service to stop, before it starts it. In other words, the "net stop" command is "blocking", and will not return until the service stops, and then the next batch command (net start) is executed.. If you use the hyperserver, it is of course the webserver service that runs the ISAPI modules that has to be stopped and started, aka restarted. I am not sure, however, if this will work from an Unigui app, when I think about it, as you may need administrator privileges. In that case, you may have to create a desktop app, which you run as admin at startup, and communicates with the Ungui app, to run the batch file. Quote Link to comment Share on other sites More sharing options...
irigsoft Posted October 24, 2023 Share Posted October 24, 2023 18 hours ago, Ron said: if this will work from an Unigui app, when I think about it, as you may need administrator privileges. maybe not if you use this in bat file: set "params=%*" cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B ) net stop YOURServiceName net start YOURServiceName //pause or this file: Restart_application.bat Quote Link to comment Share on other sites More sharing options...
sicoobcooplivre Posted October 24, 2023 Author Share Posted October 24, 2023 I'll try! Please, just to close this doubt, does anyone know why the "shutdown server" option appears disabled as I posted above? Doesn't this option also work for stop/restart? Thank you all very much for your answers and help! Quote Link to comment Share on other sites More sharing options...
Tokay Posted October 24, 2023 Share Posted October 24, 2023 'Shutdown server' does not work in the service mode, maybe you've use it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.