473,320 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Synchronizing datetime of computers

Hello,

How can be synchronize dates of two computers.
I tried this using net time command but this works fine in Console
application but fails in web application.

Can any help me out.

My code is as follows

FileStream stream = File.Create( @"C:\batch.bat" );
byte[] b = System.Text.Encoding.ASCII.GetBytes( @" net time
\\machinename-with-whom-to-sync /set /yes" );
stream.Write( b, 0, b.Length );
stream.Close( );
Process p1 = new Process( );
p1.EnableRaisingEvents = false;
p1.StartInfo.FileName= "C:\\batch.bat";
p1.StartInfo.CreateNoWindow = true;
p1.StartInfo.UseShellExecute = false;
p1.Start( );
p1.WaitForExit( );

Thanks,
Sushi
Nov 17 '05 #1
2 2094
Try this. Remove the "> c:\\output.txt" after your happy with the output.
You could also run it without CMD. I just did with CMD for debug reasons.
In that case the fileName would be "Net" and the args would be all after
"net" below.

string machine = @"\\wjs";
Process p1 = new Process();
p1.StartInfo.FileName = "cmd";
p1.StartInfo.Arguments = "/c net time " + machine + " /set /yes
c:\\output.txt"; p1.StartInfo.CreateNoWindow = true;
p1.StartInfo.UseShellExecute = false;
p1.Start();
p1.WaitForExit();

--
William Stacey [MVP]

"sushi" <su***@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com... Hello,

How can be synchronize dates of two computers.
I tried this using net time command but this works fine in Console
application but fails in web application.

Can any help me out.

My code is as follows

FileStream stream = File.Create( @"C:\batch.bat" );
byte[] b = System.Text.Encoding.ASCII.GetBytes( @" net time
\\machinename-with-whom-to-sync /set /yes" );
stream.Write( b, 0, b.Length );
stream.Close( );
Process p1 = new Process( );
p1.EnableRaisingEvents = false;
p1.StartInfo.FileName= "C:\\batch.bat";
p1.StartInfo.CreateNoWindow = true;
p1.StartInfo.UseShellExecute = false;
p1.Start( );
p1.WaitForExit( );

Thanks,
Sushi

Nov 17 '05 #2
hello,

I tried this but still it works fine in console application but does not
work in web application.

Thanks,
Sushi

"William Stacey [MVP]" wrote:
Try this. Remove the "> c:\\output.txt" after your happy with the output.
You could also run it without CMD. I just did with CMD for debug reasons.
In that case the fileName would be "Net" and the args would be all after
"net" below.

string machine = @"\\wjs";
Process p1 = new Process();
p1.StartInfo.FileName = "cmd";
p1.StartInfo.Arguments = "/c net time " + machine + " /set /yes
> c:\\output.txt";

p1.StartInfo.CreateNoWindow = true;
p1.StartInfo.UseShellExecute = false;
p1.Start();
p1.WaitForExit();

--
William Stacey [MVP]

"sushi" <su***@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com...
Hello,

How can be synchronize dates of two computers.
I tried this using net time command but this works fine in Console
application but fails in web application.

Can any help me out.

My code is as follows

FileStream stream = File.Create( @"C:\batch.bat" );
byte[] b = System.Text.Encoding.ASCII.GetBytes( @" net time
\\machinename-with-whom-to-sync /set /yes" );
stream.Write( b, 0, b.Length );
stream.Close( );
Process p1 = new Process( );
p1.EnableRaisingEvents = false;
p1.StartInfo.FileName= "C:\\batch.bat";
p1.StartInfo.CreateNoWindow = true;
p1.StartInfo.UseShellExecute = false;
p1.Start( );
p1.WaitForExit( );

Thanks,
Sushi


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Keith Veleba | last post by:
Hello to all fellow c.l.p'ers! Long-time listener, first-time caller. Background: I'm working on a project where I have to do some serious multithreading. I've worked up a decorator in Python...
0
by: SQLServer007 | last post by:
25 more days until the "get it free" promotion runs out for xSQL Object (you can get it from http://www.x-sql.com) Here are just some of the great features packed in the product: - Compare SQL...
5
by: Chris B | last post by:
I have the following situation: Process 1 creates Process 2 (using Process.Start(startInfo) Process 1 needs to wait until Process 2 is initialized before Process 1 can continue to execute Both...
0
by: Vagabond Software | last post by:
I posted this problem earlier and now have more information. I use the DataTable Select method to get find the most recent "LastModified" date in a table of similarly named files. I then use the...
10
by: Kim Hellan | last post by:
I have a simple string in the format "DD-MM-YY hh:mm:ss", that I need to convert to a DateTime value. I know this is a standard problem, but please don't just link to all the MSDN pages regarding...
2
by: Christopher D. Wiederspan | last post by:
We are getting ready to move an ASP.NET application off of a single development machine and onto a "webfarm". Basically our webfarm is a bunch of identical servers with the load-balancing provided...
22
by: Merlin | last post by:
Hello everyone, I realize that I'm new to the group, but I'm hoping that someone might be able to help me out. What I'm doing is using the GNU 7zip command line utility to make a backup on my...
1
by: ssc | last post by:
I'm new to C#, but have been doing embedded programming for years. I have an application that talks to an embedded radio on the serial port of my PC. I have most of the application running pretty...
2
by: LukasMalik | last post by:
Hi all, in my application, I am using DateTime. Until I got in contact with SQL I did not try to solve this problem. Where is set DateTime format? Will somehow change application DateTime format...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.