Skip to content
⌘ NSIS Forum Archive

Executing .ppkg

17 posts

Ycos3D#

Executing .ppkg

I tryed to execute ppkg with multiple sintax : ExecuteWait,ShellExecute,nsExec::ExecToStack

When i execute with nsExec
nsExec::ExecToStack 'powershell -inputformat none -ExecutionPolicy Unrestricted -File "$INSTDIR\tempfile.ps1" '
on "tempfile.ps1" i have : Invoke-Item "ppkg_path.ppkg"
, nothing happening.My messages are:

First :
0(succes)
Second:
---------------------------
Provisioning OS deployment Setup
---------------------------
Invoke-Item : Application not found

At C:\Users\Ycos3D\Desktop\Provisioning OS deployment\tempfile.ps1:1 char:1

+ Invoke-Item "<ppkg path>"

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (🙂 [Invoke-Item], Win32Exception

+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.P

owerShell.Commands.InvokeItemCommand




---------------------------
OK
---------------------------


When i execute the command in powershell with the same parameters , the ppkg is running.


I tryed ExecWait '"C:\Windows\System32\provtool.exe" "<ppkg_path.ppkg>" ' , nothing happening.
When i run same command from cmd , the ppkg is running
JasonFriday13#
Originally Posted by Ycos3D View Post
I tryed ExecWait '"C:\Windows\System32\provtool.exe" "<ppkg_path.ppkg>" ' , nothing happening.
That's a relative path, like Anders said, use a full (absolute) path. Where are you extracting the file to? That's the full path you should be using.
Ycos3D#
ppkg_path=C:\Users\Ycos3D\Desktop\Provisioning OS deployment\

Is not the full path?

In my script is "C:\Users\Ycos3D\Desktop\Provisioning OS deployment\packagename.ppkg"
JasonFriday13#
So have you tried it like this:
Originally Posted by Ycos3D View Post
ExecWait '"C:\Windows\System32\provtool.exe" "<C:\Users\Ycos3D\Desktop\Provisioning OS deployment\packagename.ppkg>" '
Is 'ppkg_path' an environment variable? Also, for provtool.exe you should be using $SYSDIR instead of an absolute path.
Ycos3D#
I use 'ppkg_path' just in this thread. in my script is use absolute path. I will try $sysdir for system32.

Please try to execute an .ppkg(Provisioning package) file in NSIS. If you succede , please tell me the script .

I executed applications,command lines, powershell expresions,shorcuts, batch and all are running , but i think is a problem with .ppkg in NSIS.
JasonFriday13#
Originally Posted by Ycos3D View Post
I use 'ppkg_path' just in this thread.
Ok, this time post the actual code that is failing, and then we can actually try to fix it.
Ycos3D#
nsExec::ExecToStack 'powershell -inputformat none -ExecutionPolicy Unrestricted -File "$INSTDIR\tempfile.ps1" '

in tempfile.ps1 ia have just 1 line : Invoke-Item "C:\Users\Ycos3D\Desktop\Provisioning OS deployment\Upgrade_to_Enterprise.ppkg"
Ycos3D#
Originally Posted by JasonFriday13 View Post
Ok, this time post the actual code that is failing, and then we can actually try to fix it.
Is not failing, but do nothing. ExeToStack return "success".
JasonFriday13#
Alright, so time to start checking that the paths are correct, $INSTDIR\tempfile.ps1 is first. Is tempfile.ps1 being extracted to $INSTDIR? Does the file exist when calling nsExec::ExecToStack? Then in tempfile.ps1 double-check that the path is correct and that it points to a file that exists.
Ycos3D#
the file exist, i used tempfile.ps1 to open a .txt file with same script.

in tempfile.ps1 i had just 1 line : Invoke-Item "C:\Users\Ycos3D\Desktop\Provisioning OS deployment\test.txt"

For .txt file (.exe,.pdf and other extensions) works fine.
JasonFriday13#
If nsExec::ExecToStack is returning success, and it's working with other file types, then I would say that it's not a problem with NSIS. You might have to apply the file a different way, ie calling a proper tool to apply the file.
Ycos3D#
the powershell script : powershell -inputformat none -ExecutionPolicy Unrestricted -File "C:\Users\Ycos3D\Desktop\Provisioning OS deployment\tempfile.ps1" is working in "Windows Powershell" and the command : "C:\Windows\System32\provtool.exe" "<C:\Users\Ycos3D\Desktop\Provisioning OS deployment\packagename.ppkg>" is working in "Command prompt" but not working in NSIS

The ExecToStack return 0(succes) and the message is :

Invoke-Item : Application not found

At C:\Users\Ycos3D\Desktop\Provisioning OS deployment\tempfile.ps1:1 char:1

+ Invoke-Item "<ppkg path>"

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: ( [Invoke-Item], Win32Exception

+ FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.P

owerShell.Commands.InvokeItemCommand
Ycos3D#
The problem is that i can't execute some files from $SYSDIR :changepk.exe , provtool.exe
Other files that require admin acces i can run.
I tryed ExecShell "runas" and UAC plugin, but with no result.
Ycos3D#
Solved!

!include "x64.nsh"

${DisableX64FSRedirection}

nsExec::ExecToStack 'powershell -inputformat none -ExecutionPolicy Unrestricted -File "$PLUGINSDIR\tempfile.ps1" '

${EnableX64FSRedirection}