11 Replies Latest reply on Aug 23, 2010 2:17 PM by ggeldorp

    Using the ThinApp SDK from PowerShell

    LucD Guru
    Community WarriorsvExpertUser Moderators

      For the PowerShell adepts out there, you can use the ThinApp SDK from PowerShell.

      See my Using the ThinApp SDK from PowerShell post.

       

       

       

       

      ____________

      Blog: LucD notes

      Twitter: lucd22

      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
        • 1. Re: Using the ThinApp SDK from PowerShell
          Master

          Exciting to see you pick up the ThinApp SDK so fast!

           

          The target audience isn't restricted to just the Visual Studio folks, we want to make the SDK easily accessible from as many environments as possible, this most certainly includes PowerShell. If there is anything we can do to make life easier in your environment, just let us know and we'll try to accommodate you (example is the missing manifest you mentioned).

           

          To prepare the environment, all you need to do is copy ThinAppSDK.dll and ThinAppSDKSrvr.exe to the same directory and run "regsvr32 ThinAppSDK.dll" (from an elevated command prompt). There is no need to manually start ThinAppSDKSrvr.exe. ThinAppSDKSrvr.exe is used when accessing the ThinApp SDK from a 64-bit application and is started automatically by Windows when needed.

           

          Perhaps a little technical background: ThinAppSDK.dll is the DLL that implements the ThinApp SDK objects like ThinApp.Management. It is a 32-bit DLL, if you create a ThinApp.Management object from a 32-bit process Windows will load ThinAppSDK.dll into that process (if the DLL was registered correctly with regsvr32). However, it's not possible to load a 32-bit DLL into a 64-bit process. So if you try to create a ThinApp.Management object from a 64-bit process, ThinAppSDK.dll cannot be loaded directly into that process.

          That's where ThinAppSDKSrvr.exe comes in. Windows will detect this situation and will automatically launch ThinAppSDKSrvr.exe. Since ThinAppSDKSrvr.exe is a 32-bit application, it can load ThinAppSDK.dll just fine. Windows will then "forward" ThinApp SDK calls (e.g. the GetThinAppType method call) from the 64-bit process to ThinAppSDKSrvr.exe, which will in turn forward it to ThinAppSDK.dll. The result will be passed back from ThinAppSDK.dll to ThinAppSDKSrvr.exe via Windows to the 64-bit application. This might sound complicated, but it all happens behind the scenes, you shouldn't have to worry about it.

           

          So, the ThinApp SDK actually does support 64-bit applications. I just tried and launched a 64-bit PowerShell on Win7 x64. I had no problems running your samples. Not sure why it didn't work for you.

          • 2. Re: Using the ThinApp SDK from PowerShell
            LucD Guru
            User ModeratorsvExpertCommunity Warriors

            Thanks for the explanation.

            I tried it again and it works on my Windows 7 64-bit client.

            Must have done something wrong yesterday

            I'll update my post.

             

             

             

             

            ____________

            Blog: LucD notes

            Twitter: lucd22

            Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
            • 3. Re: Using the ThinApp SDK from PowerShell
              kailashgajara Novice

               

              Hi,

               

               

              I am getting this error after running the first simple script:

               

               

              File C:\..\..\ThinAppSDK-1.ps1 cannot be loaded because the execution of scripts

              is disabled on this system. Please see "get-help about_signing" for more details.

              At line:1 char:59

              + C:\...\...\ThinAppSDK-1.ps1 <<<<

                  + CategoryInfo          : NotSpecified: ( [], PSSecurityException

                  + FullyQualifiedErrorId : RuntimeException

               

               

              My system is Win 7 , 64 bit.

               

               

              Thanks.

               

               

              • 4. Re: Using the ThinApp SDK from PowerShell
                LucD Guru
                Community WarriorsUser ModeratorsvExpert

                PowerShell is configured to be secure.

                You first have to tell PowerShell which kind of scripts you want to allow to run.

                Like this

                Set-ExecutionPolicy -ExecutionPolicy "RemoteSigned"
                

                 

                 

                 

                 

                 

                ____________

                Blog: LucD notes

                Twitter: lucd22

                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                • 5. Re: Using the ThinApp SDK from PowerShell
                  kailashgajara Novice

                   

                  Thanks LuCD. I did that. "Set-ExecutionPolicy Unrestricted"

                   

                   

                  I am getting "Exception calling "OpenPackage" at $package = $thinMgmt.OpenPackage($sampleApp)

                   

                   

                  • 6. Re: Using the ThinApp SDK from PowerShell
                    Master

                    The script has the ThinApp package hard-coded in:

                     

                    $sampleApp = "C:\ThinApp\XmlPad3\bin\XmlPad.exe"

                     

                    Do you actually have a package at C:\ThinApp\XmlPad3\bin\XmlPad.exe? If not, replace by the path to one of your own packages.

                    • 7. Re: Using the ThinApp SDK from PowerShell
                      kailashgajara Novice

                      Yes, I do. Actually I am wondering whether SDK is succesfully loaded or not. I hope  regsvr32  ThinAppSDK.dll is sufficient for Setup on Win 7 64 bit.

                      • 8. Re: Using the ThinApp SDK from PowerShell
                        LucD Guru
                        User ModeratorsCommunity WarriorsvExpert

                        Do you have file ThinAppSDKSrvr.exe in the same folder from where you registered ThinAppSDK.dll ?

                        Like Greg explained, it's ThinAppSDKSrvr.exe (a 32-bit application) that will call the 32-bit DLL and pass back the results.

                         

                        You can check with MSInof32 if the DLL is loaded.

                         

                         

                         

                         

                        ____________

                        Blog: LucD notes

                        Twitter: lucd22

                        Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                        • 9. Re: Using the ThinApp SDK from PowerShell
                          kailashgajara Novice

                          Yes, I do. I have both .dll and .exe file in same folder. (It comes as it is while downloading SDK.) I enabled UAC and ran command regsvr32 ThinAppSDK.dll , and it gives me popup that it succeeded. But MSInfo32 doesn't show anything.

                          • 10. Re: Using the ThinApp SDK from PowerShell
                            LucD Guru
                            User ModeratorsCommunity WarriorsvExpert

                            You probably meant that you "...disabled UAC".

                            But could you perhaps try to run the regsvr32 from an elevated command prompt (started with run as administrator) ?

                            I don't think that a disabled UAC and "run as administrator" are the same.

                             

                             

                             

                             

                            ____________

                            Blog: LucD notes

                            Twitter: lucd22

                            Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                            • 11. Re: Using the ThinApp SDK from PowerShell
                              Master

                              If you got to the "OpenPackage" call then registration succeeded, otherwise you wouldn't get past the New-Object call.

                              Can you post the complete error message that you get when OpenPackage fails? There should be more information after the "exception" stuff.