![]() |
#1 |
Junior Member
Join Date: Oct 2018
Posts: 7
|
Restart or Refresh Installer
Is there a way to restart or refresh the installer? I don't know what my underlying issue is. I'm trying to get my installer to install SQL Server (if not installed) and build a database. As long as SQL Server is there when the installer starts, the database is built as expected. It won't build the database on a single run if it needs to install SQL Server first. However, if I run it once to install SQL Server, and then a second time to build the database, everything works fine.
I've tried using Sleep after installing SQL Server, but that doesn't help. I even made a console app that waits for a few seconds and opens the installer. I have my installer execute (using Exec) this app and then Quit. As expected, the installer installs SQL server, opens the console app, and closes the installer (the dialog disappears). After a few seconds, the app starts up the installer again. The installer recognizes that the new SQL Server instance exists (it runs a repair without issues), but it still won't use the instance to build my database unless I manually close and restart the installer. Here's the error text I get when I cannot build the database: SQLCMD.EXE - Application Error The application was unable to start correctly (0xc000007b) I can easily generate this error buy trying to open sqlcmd after uninstalling all instances of SQL Server. What is happening when I manually close and restart that is not happening when I programmatically close and restart? How can I make sure that SQL Server is ready to be used after installing it? I'm guessing that the system doesn't know my installer has installed SQL Server until the installer COMPLETELY closes, but I don't know what to do about it. |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Something related to %path%?
Starting something from Explorer gives you the new %path% (if somebody modified it) but restarting the installer from itself will not. IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Oct 2018
Posts: 7
|
Solution
Thank you, Anders! You got me heading in the right direction. Since the PATH variables weren't updated, SQLCMD could not be executed. I was however, able to execute a "where" search for sqlcmd and find it that way. Essentially what I did was this:
code: The StrLoc Function and macro came from here. I also used this Trim function, though I'm not certain it was necessary. |
![]() |
![]() |
![]() |
#4 |
Junior Member
Join Date: Apr 2018
Posts: 11
|
Interesting solution. I've run into this problem as well. I ended up just hardcoding in the paths for the sqlcmd.exe for each version of SQL 08R2,2012,2014,2016,2017 that I install. Although your solution allows you to install it to a custom location within Programfiles. You could remove the /r and then open it up to all locations.
Ideally you can look into refreshing the paths during runtime. That would be the best solution. |
![]() |
![]() |
![]() |
#5 |
Junior Member
Join Date: Oct 2018
Posts: 7
|
I initially tried it without the /r before I realized that "by default, the search is done in the current directory and in the PATH". I believe I need the recursive search, since sqlcmd won't be in either place. If there is a way to search everywhere, it would still be faster to restrict the search program files.
I do agree it would be better to refresh the paths. Thanks for the comments. |
![]() |
![]() |
![]() |
#6 | |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
You can try
Quote:
Use the EnVar plug-in if you want to update %path% in the registry yourself. IntOp $PostCount $PostCount + 1 |
|
![]() |
![]() |
![]() |
#7 |
Junior Member
Join Date: Dec 2018
Posts: 3
|
I have the same problem.
Anders, how should I use this line? System::Call 'SHELL32::RegenerateUserEnvironment(*p,i1)i' Should I just insert it in my script? I tried to run it just in cmd and had the following: "The filename, directory name, or volume label syntax is incorrect." |
![]() |
![]() |
![]() |
#8 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
Yes just put it in a Section before you Exec. I did not test so I'm not sure if it actually works.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#9 |
Junior Member
Join Date: Dec 2018
Posts: 3
|
![]()
Yes, it works like a charm! Thanks a lot!
How do you learn about this command? What do parameters (*p,i1,i') mean in the command ? |
![]() |
![]() |
![]() |
#10 |
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,548
|
This function is undocumented but you can look at the implementation in ReactOS if you are curious. I don't know what Microsoft names the parameters, I just looked at ReactOS/Wine.
IntOp $PostCount $PostCount + 1 |
![]() |
![]() |
![]() |
#11 |
Junior Member
Join Date: Dec 2018
Posts: 3
|
Ok, great, thank you Anders!
|
![]() |
![]() |
![]() |
#12 |
Major Dude
Join Date: May 2005
Location: New Zealand
Posts: 923
|
Just so you know, I've updated my EnVar plugin and added an update function so that you can refresh environment variables for the installer process, for example if %path% was changed externally while the installer is still running
![]() "Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me) NSIS 3 POSIX Ninja Wiki Profile |
![]() |
![]() |
![]() |
|
Tags |
database, refresh, restart |
Thread Tools | Search this Thread |
Display Modes | |
|
|