Click here to Skip to main content
15,900,396 members
Home / Discussions / C#
   

C#

 
QuestionHow to make Property window readonly at runtime [modified] using c# Pin
subhash1 2311-May-08 21:08
subhash1 2311-May-08 21:08 
AnswerRe: How to make Property window readonly at runtime [modified] using c# Pin
Christian Graus11-May-08 22:09
protectorChristian Graus11-May-08 22:09 
Questionsearch for torrent files Pin
Umesh873811-May-08 21:02
Umesh873811-May-08 21:02 
AnswerRe: search for torrent files Pin
Christian Graus11-May-08 21:05
protectorChristian Graus11-May-08 21:05 
GeneralRe: search for torrent files Pin
Umesh873811-May-08 21:19
Umesh873811-May-08 21:19 
GeneralRe: search for torrent files Pin
Christian Graus11-May-08 21:24
protectorChristian Graus11-May-08 21:24 
GeneralRe: search for torrent files Pin
Umesh873811-May-08 21:27
Umesh873811-May-08 21:27 
Questiontransfer parameter to thread via .NET 1.0 [modified] Pin
shinboxe11-May-08 20:52
shinboxe11-May-08 20:52 
Hello,
Im using visual studio .NET Version 1.0 and unfortunately because of cash flow reasons i cant upgrade to a new version .. so i would appreciate if answers would be based on the 1.0 version
I made a program who needs to select a desktop computers out of a list taken from the AD and to remote connect the computer and silent install the specified Software.. so far it went good.. but when i have tried to use this code based on a multiply computers (using threads ofcourse) i cant seem to transfer the parameter i want .. i have tried using delegation and to for the function and i haven't succeeded,so i ended up with declaring a private class variable
im adding the code:
private void button1_Click(object sender, System.EventArgs e)<br />
		{<br />
			string s="";<br />
			<br />
			int count=listBox2.SelectedItems.Count;<br />
			Thread[] th=new Thread[count];<br />
				//th[count]= new Thread(new ThreadStart(button1C));<br />
			<br />
			for(int i=0;i!=listBox2.SelectedItems.Count;i++)<br />
			{<br />
				th[i]=new Thread(new ThreadStart(button1C));<br />
				ComputerName=s;<br />
				th[i].Start();<br />
				<br />
			}<br />
		}<br />
<br />
		private void button1C()<br />
		{<br />
				<br />
			string Software="";<br />
			int i=0;<br />
			ProgramPath="";<br />
			string path =Application.StartupPath +  @"\SCRIPTS.txt";												<br />
			try<br />
			{<br />
				if((comboBox1.SelectedItem == null) || (textBox2.Text==""))<br />
					throw new Exception();<br />
								<br />
			}<br />
			catch <br />
			{<br />
				MessageBox.Show("áçø úåëðä åîçùá","ùâéàä!");<br />
				return;<br />
			}<br />
			Software=comboBox1.SelectedItem.ToString();<br />
	//		ComputerName=textBox2.Text;<br />
			for (i=0;i<DBScript.Count;i++)<br />
			{<br />
				if (Software==DBScript[i].ToString())<br />
				{<br />
					ProgramPath=DBScriptname[i].ToString();<br />
					break;<br />
				}<br />
			}<br />
<br />
			creating_batchfile(ComputerName,ProgramPath);<br />
			pictureBox1.Image = new System.Drawing.Bitmap(Application.StartupPath + @"\2.png");<br />
			MessageBox.Show("ääú÷ðä äåùìîä!");<br />
<br />
		}<br />
<br />
		private void creating_batchfile(string Compname,string script)<br />
		{<br />
			string source = @"\\"+ Compname + @"\c$\" +  @"silent.bat";<br />
			StreamWriter sw;<br />
			sw=File.CreateText(source);<br />
			sw.WriteLine(script);<br />
			sw.Close();<br />
<br />
			<br />
			System.Diagnostics.Process PP = System.Diagnostics.Process.Start("cmd.exe",@" /c " + @"psexec " + @" \\" + ComputerName +  @" -u user -p 1234567 -i c:\silent.bat");<br />
			while (PP.HasExited != true){}<br />
			System.IO.File.Delete(source);<br />
<br />
		}


now the error the program writes me (when im trying to send couple of threads away - each for every computer) is that it cant create sw=File.CreateText(source); because some other program is using it ..
i looked it through and from my point of view it doesnt pass the Compname parameter right..

Thanks for all of your help!

Liran.

modified on Monday, May 12, 2008 3:37 AM

AnswerRe: transfer parameter to thread via .NET 1.0 Pin
#realJSOP11-May-08 23:47
professional#realJSOP11-May-08 23:47 
GeneralRe: transfer parameter to thread via .NET 1.0 Pin
shinboxe12-May-08 3:02
shinboxe12-May-08 3:02 
GeneralRe: transfer parameter to thread via .NET 1.0 [modified] Pin
#realJSOP12-May-08 5:27
professional#realJSOP12-May-08 5:27 
Questionhow to merge contents of files into single file Pin
uglyeyes11-May-08 20:44
uglyeyes11-May-08 20:44 
AnswerRe: how to merge contents of files into single file Pin
Christian Graus11-May-08 20:48
protectorChristian Graus11-May-08 20:48 
QuestionMDI Pin
benjamin yap11-May-08 20:43
benjamin yap11-May-08 20:43 
AnswerRe: MDI Pin
greekius11-May-08 21:08
greekius11-May-08 21:08 
GeneralRe: MDI Pin
benjamin yap11-May-08 22:53
benjamin yap11-May-08 22:53 
GeneralRe: MDI Pin
natsuyaki11-May-08 23:13
natsuyaki11-May-08 23:13 
QuestionOUTLOOK Connector Pin
mohant$.net11-May-08 20:21
mohant$.net11-May-08 20:21 
QuestionHow to embed Excel spreadsheet in Windows forms application Pin
nilam247711-May-08 19:53
nilam247711-May-08 19:53 
AnswerRe: How to embed Excel spreadsheet in Windows forms application Pin
Spunky Coder11-May-08 20:14
Spunky Coder11-May-08 20:14 
QuestionRe: How to embed Excel spreadsheet in Windows forms application Pin
nilam247711-May-08 20:39
nilam247711-May-08 20:39 
AnswerRe: How to embed Excel spreadsheet in Windows forms application Pin
Christian Graus11-May-08 20:48
protectorChristian Graus11-May-08 20:48 
Questionhow to by pass login page??? Pin
Ron.S11-May-08 19:20
Ron.S11-May-08 19:20 
AnswerRe: how to by pass login page??? Pin
Christian Graus11-May-08 19:37
protectorChristian Graus11-May-08 19:37 
Questioncode signing the assemblies Pin
ananthrahul11-May-08 19:13
ananthrahul11-May-08 19:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.