1

I have a lot of powershell modules that I have been working on, and I have been tasked with distributing them as a single executable. I made a batch script to run my powershell stuff and I am using that batch script as the target of a WinRAR SFX executable.

The issue is that when I run the script through the batch file, everything works fine, but when I run I run it through the executable, the script has errors. These errors are not "Failure" errors, but exceptions thrown by my own powershell script. My powershell code is running differently when it is run through batch or through WinRAR SFX. Has anyone experienced this and know how to fix it?

If you want more information on the type of error my powershell is throwing, in my script I am doing a breadth first search on a small portion of the registry. When I run it with the batch script wrapper, it runs in ~30 seconds with no errors. When I run it with the WinRAR SFX Executable, it throws this error:

Cannot convert argument "index" with value "CLSID", for "GetValue" to 
type "System.Int64": Cannot convert value "CLSI" to type "System.Int64".
Error: "Input string was not in a correct format.""At 
C:\Users\Administrator\AppData\Local\Temp\RarSFX0\myscript.ps1:270 
char:33
+                         elseif ($key.getValue("CLSID") -new $null {
+ 
    + CategoryInfo           : NotSpecified:  (:) [], MethodException
    + FullyQualifiedErrorId  : MethodArgumentCovnersionInvalidCastArgument

After checking the types of all of the objects I am examining, at some point my registry key object becomes an array of registry key objects in the WinRAR version but not the batch version. Any ideas?

Jake Sandler
  • 162
  • 1
  • 8
  • 32-bit vs 64-bit? Because if you're in 32-bit mode, and I bet WinRAR SFX is, you might well be searching a different part of the registry than on any tests you might have done. – Chris Dent Aug 09 '16 at 12:29
  • I already tried that. Running 32 bit powershell from the batch file still works fine. Plus I test that each key exists before I operate on it, so I shouldn't be getting errors even if it can't find the keys. – Jake Sandler Aug 09 '16 at 12:34
  • What is the object type for $key? Can you provide some of your code to help understand where your objects are coming from? – nabrond Aug 09 '16 at 13:43

0 Answers0