Having problems with EXE conversion using PSCX

Topics: Developer Forum
Jan 30, 2013 at 2:18 PM

Hi All,

I have a piece of code pasted below, all i am doing is converting my powershell script to EXE using PSCX. But when i try to double click that file i get a message saying that .exe is failed, "Close the program or Debug the program"

Can someone help me what possibly could i be doing wrong?

+++++++++++++++++++++++++++++++++++++++++++++++++++++

Add-PSSnapin Microsoft.SharePoint.PowerShell

function Invoke-FileBrowser
{

[System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”)
$FileBrowser = New-Object System.Windows.Forms.OpenFileDialog
$FileBrowser.InitialDirectory = "C:\"
$FileBrowser.Filter = "All Files (*.*)| *.*"
$FileBrowser.Title = "Browse"
$FileBrowser.ShowHelp = $true
$Show = $FileBrowser.ShowDialog()
}

Invoke-FileBrowser

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Coordinator
Jan 31, 2013 at 4:40 PM
Edited Jan 31, 2013 at 4:40 PM
Try removing the Add-PSSnapin Microsoft.SharePoint.PowerShell command and see if you can get just the file browser to work. I'm wondering if the SharePoint snapin is bit-specific and the EXE is running in a non-compatible bitness i.e. 64-bit where maybe the SharePoint snapin is 32-bit only. I'm just guessing here as I have no experience with this snapin.

BTW exe conversion isn't a PSCX feature. It's just a script I wrote and blogged about.