如何远程自动更改远程XP专业PC的日期和小时? [英] How can I remotely and automatically change the date and hour of a remote XP Pro PC?
问题描述
大家好,
首先让我介绍一下我的问题:
我有一个小型服务器,为用户提供远程许可证以使用会计师程序。
该程序要求所有使用它的计算机都在同一天(即如果我想让会计师程序在我的电脑我的电脑和许可证服务器必须在同一天和同一时间内。
这个会计师程序的另一个问题是如果你想要介绍属于2012的数据,你必须在2012年(一旦你的电脑进入2013年就不能这样做)这是废话。
现在我面对一个愚蠢的问题:
我想允许会计师远程更改日期和时间(它应该是一个小程序,这样可以完成这个很容易,无需让他们(会计师)访问服务器。
任何想法o如何完成这项工作?
提前谢谢!
Hello all,
Dirst of all let me introduce my problem:
I have a small server that is giving users remote licences to use the accountants program.
That program requires all the computers that work with it to be on the same date (i.e. If I want to get the accountants program working in my computer my computer and the license server must be on the same date and in the same hour).
Another problem that this accountants program has is that if you want to introduce data that belongs to 2012 you must be at 2012 (you can''t do that once your computer has entered 2013) which is crap.
So now I face a stupid problem:
I would like to allow the accountants to remotely change the date and time (it should be a small program or so which would allow to get this done easily without needing to give them (the accountants) access to the server).
Any idea on how to get this done?
Thank you in advance!
推荐答案
管理对象(WMI)如果你使用XP或更高版本,这是一个很好的方法。
Management Object(WMI) is a good method if you use XP or later.
public void SetSystemTime(string host, string username, string password, DateTime dt)
{
ConnectionOptions options = new ConnectionOptions();
options.Username = username;
options.Password = password;
path = new ManagementPath(String.Format("\\\\{0}\\root\\cimv2", host));
scope = new ManagementScope(path, options);
foreach (ManagementObject classInstance in new ManagementClass(scope, new ManagementPath("Win32_OperatingSystem"), null).GetInstances())
{
// Obtain in-parameters for the method
ManagementBaseObject inParams = classInstance.GetMethodParameters("SetDateTime");
// Add the input parameters.
inParams["LocalDateTime"] = ManagementDateTimeConverter.ToDmtfDateTime(dt);
// Execute the method and obtain the return values.
ManagementBaseObject outParams = classInstance.InvokeMethod("SetDateTime", inParams, null);
}
}
另外,你可以使用PSTools:
http://technet.microsoft.com/en-us/sysinternals/ bb897553 [ ^ ]
PsExec.exe -u domain / username -p password \\RemoteServerName cmd / C date 07-11-2010
你可以使用它并创建一个小的.Net程序。使用System.Diagnostic.Process.Start(上面的命令)
注意:使用内部Process.Start方法时使用PsExec.exe的完整路径
谢谢,
Kuthuparakkal
Alternatively, you could use PSTools:
http://technet.microsoft.com/en-us/sysinternals/bb897553[^]
PsExec.exe -u domain/username -p password \\RemoteServerName cmd /C date 07-11-2010
You could use this and create a small .Net Program. Use System.Diagnostic.Process.Start("the above command")
Note: Use full path to PsExec.exe when you use inside Process.Start method
Thanks,
Kuthuparakkal
这篇关于如何远程自动更改远程XP专业PC的日期和小时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!