Answer the question
In order to leave comments, you need to log in
Calling a powershell script with an argument
I have a script written in powershell. For the purity of the experiment, let's say it contains only one line:
exit 0
Create a section in the registry HKEY_CURRENT_USER\Software\Classes\*\shell\mycheck
We see that the item mycheck has appeared in the context menu of the file manager
Create another section in the registry Enter HKEY_CURRENT_USER\Software\Classes\*\shell\checksum\command
its default value
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -command "& 'C:\Users\myuser\Documents\mycheck.ps1' '%1' "
Respectively replace the user name with your own.
This allows you to pass a filename to the script. Everything works on any file except *.exe !
If you call the script for execution and pass it the name of the exe file (not from the console, but from the context menu), then the program passed as an argument is launched for execution.
I assume that it is solved by some kind of shielding ...
Who has a solution to the problem?
PS OS Windows 7
Answer the question
In order to leave comments, you need to log in
Created c:\test.ps1 with the following content:
powershell -noexit "echo $args"
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -EP Bypass -File C:\test.ps1 "%1"
param($FilePath)
powershell -noexit "echo $FilePath"
C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe -EP Bypass -File C:\test.ps1 -FilePath "%1"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question