okay so i have this button

private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog fDialog = new OpenFileDialog();
            fDialog.Title = "Open Injector";
            fDialog.Filter = fDialog.Filter = "Exe Files|*.exe";
            fDialog.InitialDirectory = @"C:\";
            if (fDialog.ShowDialog() == DialogResult.OK)
            {

                MessageBox.Show(fDialog.FileName.ToString());
                fDialog.CheckFileExists = true;

                fDialog.CheckPathExists = true;

            }
            string str = fDialog.FileName;
            Process process = new Process();
            process.StartInfo.FileName = str;
            process.Start(); ;
            {
                string str1 = @"C:\Nexon\MapleStory\GameLauncher.exe";
                Process process1 = new Process();
                process1.StartInfo.FileName = str1;
                process1.Start();

            }
        }

and the problem is that only in windows 7 and vista it works with right click run as admin,and for xp its works finr like this.
how shall i check for the os and run as admin

I don't know how you might run as an administrator, but you can do a Windows 7/Vista check with this:

if(Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6) {
     // The OS is Win7 or Vista
} else {
     // It's something else
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.