Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 15:42

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Help]Trying to make a console with auto-restart to update Configuration.ini

Discussion on [Help]Trying to make a console with auto-restart to update Configuration.ini within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
stephanyd's Avatar
 
elite*gold: 0
Join Date: Jun 2007
Posts: 390
Received Thanks: 92
[Help]Trying to make a console with auto-restart to update Configuration.ini

Hi... i try to build a console that auto-restart and update Configuration.ini for my server but it won't restart itself. Here is the code .... someone can help me plz?

Quote:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Text;
using System.IO;
using System.Net;

namespace test1
{
class Program
{
static void Main(string[] args)
{
string MyIP = "";
try
{
try
{
IPHostEntry serverHE;
try
{
serverHE = Dns.GetHostEntry("MyHost.dyndns.info");
Console.WriteLine("Trying...");
}
catch (Exception)
{
MessageBox.Show("Host not found");
Environment.Exit(1);
return;
}
IPAddress IP = serverHE.AddressList[0];
MyIP = IP.ToString();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
if (File.Exists(System.Windows.Forms.Application.Star tupPath + @"\configuration.ini"))
{
string[] content = new string[1] { MyIP };
File.WriteAllLines(System.Windows.Forms.Applicatio n.StartupPath + @"\configuration.ini", content);
List<string> Lines = new List<string>();

Lines.Add("[Configuration]");
Lines.Add("IP=" + MyIP.ToString());
Lines.Add("GamePort=5816");
Lines.Add("AuthPort=9958");
Lines.Add("ServerName=ServerName");
Lines.Add("");
Lines.Add("[MySql]");
Lines.Add("Host=localhost");
Lines.Add("Username=root");
Lines.Add("Password=password");
Lines.Add("Database=Database");
Lines.Add("");
Lines.Add(";192.168.1.103");
Lines.Add(";70.42.74.212");
Lines.Add(";unknownpassword");

File.WriteAllLines("configuration.ini", Lines.ToArray());
Console.WriteLine("IP Updated Successfully!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
Environment.Exit(0);
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run();
{
if (DateTime.Now.DayOfWeek == DayOfWeek.Friday && DateTime.Now.Minute == 20 && DateTime.Now.Second == 00)
{
Application.Restart();
Environment.Exit(0);
}


}
}
}
}
stephanyd is offline  
Old 05/31/2013, 20:47   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
Where does it go wrong?

I expect your problem is you're using File.WriteAllLines multiple times. I haven't used it before but I'm pretty sure it's overwriting the content of the file every time you write.

You should likely be adding all your strings via Lines.Add(text) and then once they are all added you can use File.WriteAllLines

That being said you've given us zero information on where the code has an issue. Breakpoint and get back to us.
pro4never is offline  
Old 05/31/2013, 21:00   #3
 
stephanyd's Avatar
 
elite*gold: 0
Join Date: Jun 2007
Posts: 390
Received Thanks: 92
Quote:
Originally Posted by pro4never View Post
Where does it go wrong?

I expect your problem is you're using File.WriteAllLines multiple times. I haven't used it before but I'm pretty sure it's overwriting the content of the file every time you write.

You should likely be adding all your strings via Lines.Add(text) and then once they are all added you can use File.WriteAllLines

That being said you've given us zero information on where the code has an issue. Breakpoint and get back to us.
Hi Pro ... all code work fine .... problem is the Application.Restart won't make application restart. anything missing in my code?
stephanyd is offline  
Old 05/31/2013, 23:08   #4
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
Why are you using it at all? From what I can see this program should be executing your code every Friday.

You can do a couple things.


#1: Leave the program running. Use a timer/while loop or some other method to determine how often your save code is being run

#2: Run a batch file that runs a certain app (which closes when it is done every X hours

#3: Look into Scheduling tasks in windows (likely the best solution if you want it to happen say... once a week)
pro4never is offline  
Reply


Similar Threads Similar Threads
How can make direct connect and auto update ?
04/08/2012 - SRO Private Server - 0 Replies
I've 8gb ram pc and i have server. But ppl can connect with hamachi. How can i make this direct connect like as vps? I forwarded all ports (i think). Im write ip 192.168... to ini files cert ok, global manager ok but machine manager, download manager etc. close accidently when i run'em. 2nd problem about auto update. It saysa damaged when update client at launcher ? Thanks. Up... upp
Auto Restart
04/12/2010 - CO2 Private Server - 11 Replies
can someone give me a code to restart the server every 2 1/2 hours.
NEW TBOT AUTO CONFIGURATION
11/06/2007 - SRO Hacks, Bots, Cheats & Exploits - 6 Replies
I make a auto configuration for tbot and work !!!!!!:) get from RapidShare: 1-Click Webhosting No have virus or keylogger.



All times are GMT +2. The time now is 15:42.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.