473,396 Members | 2,061 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,396 software developers and data experts.

Remote machine time using NET TIME

115 100+
i'm using Vb.net.
i need to find out the remote machine's time by using NET TIME.

NET TIME [\\computer | /WORKGROUP:wgname] [/SET] [/YES]

i got this help from internet while searching. but while using this code i'm not able to display the time in my machine in "cmd".

anyidea how can i find the remote machine time using NET TIME. if u have please let me know.

thanks in advace
May 25 '07 #1
6 19554
Plater
7,872 Expert 4TB
Well I just put in NET TIME at a command prompt and got back the time from my domain controller.
Expand|Select|Wrap|Line Numbers
  1. C:\Documents and Settings\Plater>net time
  2. Current time at \\DSERVER is 5/25/2007 9:33 AM
  3.  
  4. The command completed successfully.
  5.  
So what is the issue you are having?
May 25 '07 #2
remya1000
115 100+
i need to synchrinize the remote machine's time.

i tried this code

net time \\servername

and i'm getting the remote machine's time
and while using this

net time \\servername /set /yes

i can synchronize the remote machine's time too.

anyway thanks a lot to help me..... thanks...
May 25 '07 #3
You can use the System.Management WMI stuff.

In your .Net documenation:

Search "Advanced Programming Topics in WMI .NET " and check out the "How To: Connect to a Remote Computer"

Then lookup the WMI topics
- Win32_LocalTime to develop and use a "Select * from Win32_LocalTime" WMI query.
- "WMI Update Query Language" to form an update query to change the time.
May 26 '07 #4
Plater
7,872 Expert 4TB
i need to synchrinize the remote machine's time.
i tried this code

net time \\servername

and i'm getting the remote machine's time
and while using this

net time \\servername /set /yes

i can synchronize the remote machine's time too.
anyway thanks a lot to help me..... thanks...
So just run that code in your program then? Or use the WMI if you want to learn it
May 29 '07 #5
try command

net time /set \\servername
May 29 '07 #6
kombsh
3
You can get it by using below code without WMI usage (http://www.morgantechspace.com/2013/...tem-using.html)

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4.  
  5. namespace RemoteSystemTime
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             try
  12.             {
  13.                 string machineName = "vista-pc";
  14.                 Process proc = new Process();
  15.                 proc.StartInfo.UseShellExecute = false;
  16.                 proc.StartInfo.RedirectStandardOutput = true;
  17.                 proc.StartInfo.FileName = "net";
  18.                 proc.StartInfo.Arguments = @"time \\" + machineName;
  19.                 proc.Start();
  20.                 proc.WaitForExit();
  21.  
  22.                 List<string> results = new List<string>();
  23.  
  24.                 while (!proc.StandardOutput.EndOfStream)
  25.                 {
  26.                     string currentline = proc.StandardOutput.ReadLine();
  27.  
  28.                     if (!string.IsNullOrEmpty(currentline))
  29.                     {
  30.                         results.Add(currentline);
  31.                     }
  32.                 }
  33.  
  34.                 string currentTime = string.Empty;
  35.  
  36.                 if (results.Count > 0 && results[0].ToLower().StartsWith(@"current time at \\" + machineName.ToLower() + " is "))
  37.                 {
  38.                     currentTime = results[0].Substring((@"current time at \\" +
  39.                                   machineName.ToLower() + " is ").Length);
  40.  
  41.                     Console.WriteLine(DateTime.Parse(currentTime));
  42.                     Console.ReadLine();
  43.                 }
  44.             }
  45.             catch (Exception ex)
  46.             {
  47.                 Console.WriteLine(ex.Message);
  48.                 Console.ReadLine();
  49.             }
  50.         }
  51.     }
  52. }
Sep 3 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Douglas Harber | last post by:
If I have DB2 8.1 (FP5, I believe, but not relevant to my question...I hope) installed on my desktop, do I have what I need to connect to a remote DB2 server (also running 8.1 FP5) from my desktop...
2
by: felecha | last post by:
I'm stumped. I'm working on an application in VB.Net that uses System.Messaging.MessageQueue to listen for messages sent to a private queue on a remote machine. Both machines are in the same...
3
by: Nick | last post by:
Hello all, I've spent a lot of my time on this issue, and I thought it best to share my solution with the community. A special thanks to Willy Denoyette for his help. Ive opened about two...
9
by: RvGrah | last post by:
After much hair-pulling, I've finally found the answer to a problem that many are fighting with, difficulty connecting from Sql 2005 Server Management or VS2005 to a remote Sql Server running Sql...
3
by: Geoff McElhanon | last post by:
I have been struggling with a security issue that occurs under .NET 2.0, but does not occur under .NET 1.1. Essentially I am trying to open up a performance counter on a remote server and monitor...
15
by: =?Utf-8?B?TVNU?= | last post by:
To demonstrate my problem, I have a very simple VB Windows application. It has a text box that is used to display a counter, a button to reset the counter, and a timer that increments the counter...
7
by: Chris Marsh | last post by:
All I've been asked run a VM on my development machine, with Windows Server 2003 installed. I've also been asked to then develop against this environment from the host machine, using Visual...
11
by: =?Utf-8?B?U2FsYW1FbGlhcw==?= | last post by:
Has anybody worked with performancecounter object to access counters on remote machine? I managed to write code that retrieves counters categories froma remote machine, when I try another remote...
5
by: =?Utf-8?B?QWRyaWFuTW9ycmlz?= | last post by:
Hello! I'm trying to copy a file from another computer on the network that I do not have permission with my current logon details to access. If I open the folder using the Windows file manager...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.