c# batch dosyası kullanarak ipconfig Yazdır
Kullanıcı Değerlendirmesi: / 0
ZayıfEn iyi 
ilyas tarafından yazıldı   
Cuma, 13 Mart 2009 19:05

Merhaba arkadaşlar.Bilgisaranızı seyyar olarak kullanıyorsanız yani iş yerine ordan eve sürekli dolandırıyorsanız ip ayarı yapmak artık bi işkence gibi olmaya başlıyor.Ben bilgisayarı hergün okula götürüyorum ve akşamları eve geliyorum tabiki gittigim yerin de kendine ait ağı ve ip sini girmem lazım.Bende düşündüm ve biraz yardımla kendime ait ip config proogramı yaptım.Tam bitmedi henüz cünkü şimdide bilgisayarımın trafosu yandı:( ve tamamlıyamadım.Bana göre oldu ama tabikizi sizlere göre henüz kaydet bölümü yok.Bikaç gün içerisinde onuda inşallah yetiştiricem bilgisayarım gelsinde bi:)program başta bulundurdugunuz network kartlarını tarıyor ve sizin sadece local network ile wireless network iplerine değişebiliyoruz.C# application program olup batch dosyası kullandım ancak xp de problem.Vistada güvenlik sorgusu oldugu için bu Batch dosyasını bi türlü ayarlıyamadım.BİLGİNİZ VARSA BANADA SÖYLEYİN:) batch dosyası içersinde owner gibi çalıştır diye gecen hertürlü şeyi denedim ancak olmadı.Batch file sağ klik->use owner olarak yaptıgımda ancak oluyor.MAntık aslında basit. C# ta bitane batch file oluşturuyorum ve içerisini programda atadıgım ip ,DNS ,Ağ Geçidi ni yazıyorum ve bir fonksiyon ile bu batch dosyasını çalıştırıyorum.İyi çalışmalar...

  • using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
  • using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;
    using System.IO;
    using System.Net;
    using Microsoft.Win32;
  • namespace ipconfig
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            [STAThread]
           
  •          public void ayar()
            {
                Process p = null;
                try
                {
                    p = new Process();
                    
                    p.StartInfo.CreateNoWindow = true;
                    System.Diagnostics.Process.Start("cmd.exe", @"/c s.bat");
                    p.WaitForExit();
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString());
                }
  •         }
  •         private void local_Click(object sender, EventArgs e)
            {
                string a = "", b = "", c = "", d = "";
                char x = '"';
                a = "Static";
                b = "netsh int ip set address " + x + "Local Area Connection" + x + " static ";
                b += textBox11.Text + " " + textBox12.Text + " " + textBox9.Text;
                c = "netsh int ip set dns " + x + "Local Area Connection" + x + " static " + textBox10.Text + " primary";
                d = "netsh int ip add dns " + x + "Local Area Connection" + x + " " + textBox10.Text + " index=2";
  •             StreamWriter wr = new StreamWriter("s.bat");
                wr.WriteLine(a);
                wr.WriteLine(b);
                wr.WriteLine(c);
                wr.WriteLine(d);
                //MessageBox.Show(a);
                //System.Diagnostics.Process.Start("cmd.exe",a);
                wr.Close();
                ayar();
  •         }
  •         private void wireless_Click(object sender, EventArgs e)
            {
                string a = "", b = "", c = "", d = "";
                char x = '"';
                a = "Static";
                b = "netsh int ip set address " + x + "Wireless Area Connection" + x + " static ";
                b += textBox13.Text + " " + textBox14.Text + " " + textBox15.Text;
                c = "netsh int ip set dns " + x + "Wireless Area Connection" + x + " static " + textBox16.Text + " primary";
                d = "netsh int ip add dns " + x + "Wireless Area Connection" + x + " " + textBox16.Text + " index=2";
  •             StreamWriter wr = new StreamWriter("s.bat");
                wr.WriteLine(a);
                wr.WriteLine(b);
                wr.WriteLine(c);
                wr.WriteLine(d);
                //MessageBox.Show(a);
                //System.Diagnostics.Process.Start("cmd.exe",a);
                wr.Close();
                ayar();
            }
  • }
Son Güncelleme ( Çarşamba, 20 Ocak 2010 16:17 )