Powershell not finding PNPUTIL when script launched from shortcut
up vote
1
down vote
favorite
I have a Powershell script to install TCP/IP printers on Windows 10 that uses PNPUTIL to load drivers. When the script is run from a Powershell window, everything works great.
When I launch the script from a shortcut using the format
C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
I get an error 'The term 'pnputil.exe' is not recognized as the name of a cmdlet, function, script file, or operable program' when PNPUTIL is called. The rest of the script runs fine.
Relevant code:
Write-Host `n 'Installing printer driver..'
pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
Any ideas as to why this won't work when launched from a shortcut?
EDIT:I tried using
& pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
as referenced in
Running CMD command in PowerShell
but I still get the error. I also tried
start-process pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
but got a similar error that pnputil.exe could not be found.
Both of these options work from a Powershell prompt, but again, fail when launched from a shortcut.
Thank you in advance.
powershell
add a comment |
up vote
1
down vote
favorite
I have a Powershell script to install TCP/IP printers on Windows 10 that uses PNPUTIL to load drivers. When the script is run from a Powershell window, everything works great.
When I launch the script from a shortcut using the format
C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
I get an error 'The term 'pnputil.exe' is not recognized as the name of a cmdlet, function, script file, or operable program' when PNPUTIL is called. The rest of the script runs fine.
Relevant code:
Write-Host `n 'Installing printer driver..'
pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
Any ideas as to why this won't work when launched from a shortcut?
EDIT:I tried using
& pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
as referenced in
Running CMD command in PowerShell
but I still get the error. I also tried
start-process pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
but got a similar error that pnputil.exe could not be found.
Both of these options work from a Powershell prompt, but again, fail when launched from a shortcut.
Thank you in advance.
powershell
Possible duplicate of Running CMD command in PowerShell
– Harry
Nov 13 at 22:10
try to specify full path to pnputil.exe
– Mike Twc
Nov 14 at 4:00
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a Powershell script to install TCP/IP printers on Windows 10 that uses PNPUTIL to load drivers. When the script is run from a Powershell window, everything works great.
When I launch the script from a shortcut using the format
C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
I get an error 'The term 'pnputil.exe' is not recognized as the name of a cmdlet, function, script file, or operable program' when PNPUTIL is called. The rest of the script runs fine.
Relevant code:
Write-Host `n 'Installing printer driver..'
pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
Any ideas as to why this won't work when launched from a shortcut?
EDIT:I tried using
& pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
as referenced in
Running CMD command in PowerShell
but I still get the error. I also tried
start-process pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
but got a similar error that pnputil.exe could not be found.
Both of these options work from a Powershell prompt, but again, fail when launched from a shortcut.
Thank you in advance.
powershell
I have a Powershell script to install TCP/IP printers on Windows 10 that uses PNPUTIL to load drivers. When the script is run from a Powershell window, everything works great.
When I launch the script from a shortcut using the format
C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
I get an error 'The term 'pnputil.exe' is not recognized as the name of a cmdlet, function, script file, or operable program' when PNPUTIL is called. The rest of the script runs fine.
Relevant code:
Write-Host `n 'Installing printer driver..'
pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
Any ideas as to why this won't work when launched from a shortcut?
EDIT:I tried using
& pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
as referenced in
Running CMD command in PowerShell
but I still get the error. I also tried
start-process pnputil.exe /add-driver "\myServerHP UPD PCL 5hpcu180t.inf"
but got a similar error that pnputil.exe could not be found.
Both of these options work from a Powershell prompt, but again, fail when launched from a shortcut.
Thank you in advance.
powershell
powershell
edited Nov 14 at 4:03
mklement0
123k20234265
123k20234265
asked Nov 13 at 20:55
Greyula Reyula
83
83
Possible duplicate of Running CMD command in PowerShell
– Harry
Nov 13 at 22:10
try to specify full path to pnputil.exe
– Mike Twc
Nov 14 at 4:00
add a comment |
Possible duplicate of Running CMD command in PowerShell
– Harry
Nov 13 at 22:10
try to specify full path to pnputil.exe
– Mike Twc
Nov 14 at 4:00
Possible duplicate of Running CMD command in PowerShell
– Harry
Nov 13 at 22:10
Possible duplicate of Running CMD command in PowerShell
– Harry
Nov 13 at 22:10
try to specify full path to pnputil.exe
– Mike Twc
Nov 14 at 4:00
try to specify full path to pnputil.exe
– Mike Twc
Nov 14 at 4:00
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You're invoking a 32-bit instance of PowerShell on a 64-bit system, and that instance doesn't see pnputil.exe (by filename only).
Instead of:
C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
use:
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
- Folder
C:WindowsSysWOW64is where the 32-bit executables live. - Paradoxically, for historical reasons, it is
C:WindowsSystem32that houses the 64-bit executables.
If, for some reason, you do need to run a 32-bit instance of PowerShell, you can invoke pnputil.exe by its full path:
It only exists as a 64-bit executable in the 64-bit system folder, which 32-bit processes can access as C:WindowsSysNative:
C:WindowsSysNativepnputil.exe
Glad to hear it, @GreyulaReyula; my pleasure.
– mklement0
Nov 14 at 14:52
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You're invoking a 32-bit instance of PowerShell on a 64-bit system, and that instance doesn't see pnputil.exe (by filename only).
Instead of:
C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
use:
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
- Folder
C:WindowsSysWOW64is where the 32-bit executables live. - Paradoxically, for historical reasons, it is
C:WindowsSystem32that houses the 64-bit executables.
If, for some reason, you do need to run a 32-bit instance of PowerShell, you can invoke pnputil.exe by its full path:
It only exists as a 64-bit executable in the 64-bit system folder, which 32-bit processes can access as C:WindowsSysNative:
C:WindowsSysNativepnputil.exe
Glad to hear it, @GreyulaReyula; my pleasure.
– mklement0
Nov 14 at 14:52
add a comment |
up vote
1
down vote
accepted
You're invoking a 32-bit instance of PowerShell on a 64-bit system, and that instance doesn't see pnputil.exe (by filename only).
Instead of:
C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
use:
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
- Folder
C:WindowsSysWOW64is where the 32-bit executables live. - Paradoxically, for historical reasons, it is
C:WindowsSystem32that houses the 64-bit executables.
If, for some reason, you do need to run a 32-bit instance of PowerShell, you can invoke pnputil.exe by its full path:
It only exists as a 64-bit executable in the 64-bit system folder, which 32-bit processes can access as C:WindowsSysNative:
C:WindowsSysNativepnputil.exe
Glad to hear it, @GreyulaReyula; my pleasure.
– mklement0
Nov 14 at 14:52
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You're invoking a 32-bit instance of PowerShell on a 64-bit system, and that instance doesn't see pnputil.exe (by filename only).
Instead of:
C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
use:
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
- Folder
C:WindowsSysWOW64is where the 32-bit executables live. - Paradoxically, for historical reasons, it is
C:WindowsSystem32that houses the 64-bit executables.
If, for some reason, you do need to run a 32-bit instance of PowerShell, you can invoke pnputil.exe by its full path:
It only exists as a 64-bit executable in the 64-bit system folder, which 32-bit processes can access as C:WindowsSysNative:
C:WindowsSysNativepnputil.exe
You're invoking a 32-bit instance of PowerShell on a 64-bit system, and that instance doesn't see pnputil.exe (by filename only).
Instead of:
C:WindowsSysWOW64WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
use:
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -file MyScript.PS1
- Folder
C:WindowsSysWOW64is where the 32-bit executables live. - Paradoxically, for historical reasons, it is
C:WindowsSystem32that houses the 64-bit executables.
If, for some reason, you do need to run a 32-bit instance of PowerShell, you can invoke pnputil.exe by its full path:
It only exists as a 64-bit executable in the 64-bit system folder, which 32-bit processes can access as C:WindowsSysNative:
C:WindowsSysNativepnputil.exe
edited Nov 14 at 14:54
answered Nov 14 at 4:03
mklement0
123k20234265
123k20234265
Glad to hear it, @GreyulaReyula; my pleasure.
– mklement0
Nov 14 at 14:52
add a comment |
Glad to hear it, @GreyulaReyula; my pleasure.
– mklement0
Nov 14 at 14:52
Glad to hear it, @GreyulaReyula; my pleasure.
– mklement0
Nov 14 at 14:52
Glad to hear it, @GreyulaReyula; my pleasure.
– mklement0
Nov 14 at 14:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53289365%2fpowershell-not-finding-pnputil-when-script-launched-from-shortcut%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of Running CMD command in PowerShell
– Harry
Nov 13 at 22:10
try to specify full path to pnputil.exe
– Mike Twc
Nov 14 at 4:00