Call powershell script with argument


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
3 views
There is a script written in powershell. For reasons of clarity, let's say it contains only one line:
exit 0
Create the registry key HKEY_CURRENT_USER\\Software\\Classes\\*\\shell\\mycheck
We see that in the context menu of the file Manager option has been added to mycheck
Create another subkey in the registry : HKEY_CURRENT_USER\\Software\\Classes\\*\\shell\\checksum\\command
Its default value is entered
C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -command "& 'C:\\Users\\myuser\\Documents\\mycheck.ps1' '%1' "
Respectively, replace the user name on their.
This allows you to pass the script file name. On any file, everything is working except for *.exe!
If you call the script and pass it the name of the exe file (not from the console, namely from the context menu), then pass as the argument the program is run.
I suppose that is solved by some kind of shielding...
Anyone have a solution?
PS Windows 7
by | 3 views

2 Answers

0 like 0 dislike
Could use WinExec?
by
0 like 0 dislike
Created c:\\test.ps1 the following content:
\r
powershell-noexit "echo $args"

\r
Added to HKCU\\...\\test\\command\\@ next:
\r
C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -EP Bypass-File C:\\test.ps1 "%1"

\r
No difference when run exe and other files are not noticed. Generally speaking the more correct way of passing arguments to scripts — specifying the param block.
\r
test.ps1:
\r
param($FilePath) powershell-noexit "echo $FilePath"

HKCU\\...\\test\\command\\@:
\r
C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -EP Bypass-File C:\\test.ps1 -FilePath "%1"
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
27,912 users