Click here to Skip to main content
15,881,882 members

Comments by picasso2 (Top 4 by date)

picasso2 17-Sep-17 13:46pm View    
Many thanks, I placed the code inside a button (to triggered it)
using (PowerShell PowerShellInstance = PowerShell.Create())
{

PowerShellInstance.AddScript("Test-Dtc -LocalComputerName param($param1) -RemoteComputerName param($param2) -Verbose");


var localComputer = Environment.GetEnvironmentVariable("MyLocalPC");
PowerShellInstance.AddParameter("param1", localComputer);


MessageBox.Show("variable remotecomputer");
var remoteComputer = "MyRemoteSrv";
PowerShellInstance.AddParameter("param2", remoteComputer);


Collection<psobject> PSOutput = PowerShellInstance.Invoke();

MessageBox.Show("start loop");

foreach (PSObject outputItem in PSOutput)
{
MessageBox.Show("inside the foreach loop");

if (outputItem != null)
{


MessageBox.Show(outputItem.BaseObject.ToString());

}

else
{
MessageBox.Show(outputItem.BaseObject.ToString());

}

}
}

Nothing is output so I added few MessageBoxs . I noticed that message "start loop" is executed but NO code inside the foreach loop is ever gets executed.
picasso2 17-Feb-15 23:38pm View    
both your code and my code result in same output
msiexec /a "C:\Temp\MyApplication.msi" /qb TARGETDIR="C:\Temp\MyApplication.msi"

this will not run but if I copy to a batch file and then run , works fine.
-The destination folder is the same name as the msi that is why I added an EXT (extracted)to define is a extracted folder
-No the folder does not exist in the target
-path is complete and correct as you can see by the output

I will try to create the folder target first now
picasso2 21-Aug-14 0:17am View    
I tried to use the same code as ChauhanAjay recommended below. but the property BeginInit()/EndInit() cannot be found.

Image imgPhoto = new Image();
BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = new Uri("c:\\Temp\test.jpg");
bitmap.EndInit();
imgPhoto.Source = bitmap;
picasso2 20-Aug-14 22:30pm View    
The path is correct, somehow the “\” dropped when trying to format the post.
In any case,
The program compiles without errors.
If I add other controls (text, button) , just to test it
TextBlock printTextBlock = new TextBlock();
printTextBlock.Text = "Demo Text";
stackPanel1.Children.Add(printTextBlock);

Button btn = new Button();
btn.Content = "Dynamic Button";
stackPanel1.Children.Add(btn);

it works fine but trying to add an image to either the stackpanel or Image controls

Image imgPhoto = new Image();
imgPhoto.Source = new BitmapImage(new Uri("c:\\Temp\\test.jpg"));
stackPanel1.Children.Add(imgPhoto);

No image is displayed in either control. The image is a 300x300
And thus the reason asking for help

Thank you
~P