0

when I run these below commands one after another in a same powershell window , we are getting below error. And it is working when we run the second command in a new powershell window.

step 1: MsiExec.exe /i SqlLocalDB.msi IACCEPTSQLLOCALDBLICENSETERMS=YES /qn | Out-Null

step 2: sqlocaldb info

error : sqllocaldb : The term 'sqllocaldb' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

  • sqllocaldb info
  • CategoryInfo : ObjectNotFound: (sqllocaldb:String) [], CommandNotFoundException
  • FullyQualifiedErrorId : CommandNotFoundException

Any help would be appreciated to run these command in the same batch :)enter image description here

  • 1
    The installer will update the `PATH` environment variable, but since environment variables are only read once (on startup) the existing PowerShell instance isn't going to have it. There are [ways to work around that](https://stackoverflow.com/a/56562186/4137916), although they're quite complicated, and I'd personally just prefer starting a new PowerShell instance from the old one. – Jeroen Mostert Jul 22 '22 at 17:30
  • ...except that starting a new instance will inherit the parent's environment, of course, unless you jump through hoops to avoid that, so never mind that last bit. :P – Jeroen Mostert Jul 22 '22 at 17:38
  • 1
    If the issue is just that powershell doesn't know where to find `sqllocaldb`, then you can update your step 2 to use the full path for this run: `c:\path\to\sqllocaldb.exe info` – Cpt.Whale Jul 22 '22 at 17:52
  • [Reload the path in PowerShell](https://stackoverflow.com/questions/17794507) seems relevant. – AlwaysLearning Jul 22 '22 at 22:31

0 Answers0