Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 4 of 4 total |
Install EDBSrvr as a Windows service programmatically |
Wed, Oct 14 2015 10:33 PM | Permanent Link |
Jeff Cook Aspect Systems Ltd | Hi
I'm writing an installer for my application. The app runs c/s only so I need to install the EDBSrvr.exe as a service. I know how do do it manually:- EDBsrvr /install /nointeract /silent net start EDBSRVR In DelphiXE, I have tried creating a batch file like this :- sl := TStringList.Create; try sl.Add('cd ' + sBasePath); sl.Add('APMEDBsrvr /install /nointeract /silent > ServerInstall.log'); sl.Add('net start EDBSRVR > ServerStart.log'); s := sBasePath + 'Server.bat'; sl.SaveToFile(s); i := ShellExecute(handle, 'open', PChar(s), '', '', SW_HIDE); if i > 32 then LogMessage('Service installed/started') else LogMessage('Service failed but carrying on install'); finally sl.Free; end; I get this error message:- ------------------------------------ Error running the ElevateDB Server as a service: System Error. Code: 5. Access is denied ------------------------------------ .... and the ShellExecute returns 42. Any suggestions? Cheers Jeff |
Wed, Oct 14 2015 11:19 PM | Permanent Link |
Raul Team Elevate | On 10/14/2015 10:33 PM, Jeff Cook wrote:
> System Error. Code: 5. > Access is denied > ------------------------------------ > > ... and the ShellExecute returns 42. > > Any suggestions? Yes - this is normal error when your process is not running with elevated privileges. I just tried on Win8 and can easily duplicate this from regular command line - trying to install a service and i get same error. Now if run the command prompt elevated (Run as Administrator) then all works OK and service gets installed. Have not had to create an installer but my first thought is that your installer might not be running elevated so check that first. Quick googling showed also that you should probably be calling ShellExecuteEx - for example see http://edn.embarcadero.com/article/33942 and likely many other links. Raul Why are you not running the ShellExecute directly with the right parameters though and instead are creating a batch file? (or better yet CreateProcess). |
Thu, Oct 15 2015 12:09 AM | Permanent Link |
Jeff Cook Aspect Systems Ltd | On 15/10/2015 4:19 p.m., Raul wrote:
> > Yes - this is normal error when your process is not running with > elevated privileges. > > I just tried on Win8 and can easily duplicate this from regular command > line - trying to install a service and i get same error. Now if run the > command prompt elevated (Run as Administrator) then all works OK and > service gets installed. As I could do it from the command line, I presumed that when I ran my program I would have the same privileges. > Quick googling showed also that you should probably be calling > ShellExecuteEx - for example see > http://edn.embarcadero.com/article/33942 and likely many other links. > Just had a quick look at that link - looks like exactly what I want, a bit *heavy* bedtime reading > > Why are you not running the ShellExecute directly with the right > parameters though and instead are creating a batch file? (or better yet > CreateProcess). After much reading, I understand that ShellExecute(ex) doesn't wait for the command to complete ... effectively asynchronous ... without some complex code like I found in StackOverflow. This means that the "net start" would start before the server was installed. The .bat file should avoid this problem in a simple way. > Thank you Raul - looks like I'll make a bit more progress tomorrow! Cheers Jeff |
Thu, Oct 15 2015 2:40 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Jeff
Long time since I needed an installer but have you looked at InnoSetup? I think it will handle this sort of thing. Roy Lambert |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |