?
Solved

How to change or update the system date using vb?

Posted on 2012-04-11
7
Medium Priority
?
507 Views
Last Modified: 2013-12-27
The target device is a Symbol 9090 scanner running Windows CE.  My app is written in vb.net 2008.  We get the date currently in the scanner and show it in a text box using things like 'datetime.today.month' and 'datetime.today.day' etc.  Then, if it is wrong, we need to allow the user to key in the correct date, and then make it where our program can take the new date and update the scanner's system date.

How can I do this in my program--preferably in a simple way?  In searching the internet, some say you can simply set 'microsoft.visualbasic.datestring' to a string that contains the new date (which would be nice and easy), while others say the only way is to use dozens of lines of rather complex code.

I do know that I can get out of our app on the scanner, go to start> run> cmd in Windows CE, and simply type 'date 04-11-2012' to set the date--just we can do in any Windows environment.  Is there a way that is this simple from within my vb app?

I'm hoping someone can clarify for me to easiest, most direct way to do the job.  TIA
0
Comment
Question by:sasllc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
Mikal613 earned 1000 total points
ID: 37835390
0
 
LVL 3

Author Comment

by:sasllc
ID: 37835553
But I was hoping that someone would know for sure whether or not there is an easier way that writing all that code in the link mentioned.  And, at that link, it seems to indicate that the vb code provided did not work, and he had to write his own in c#--which I don't know how to use.

I also see that this was answered way back in 2003, so it gives me hope that there may be a way now, using vb.net 2008, interfacing with a Windows CE 5.0 device.

So....is there a simple way to do this in vb? If so, how would I do it?  If not, I guess I need to get an idea of the vb code needed (not c#), no matter how complicated it is--assuming there is no easy way.
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 37835559
CE 5.0 is using the old compact framework so all that "old" code is needed. That is how you do it in the CF.
0
Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

 
LVL 8

Assisted Solution

by:PagodNaUtak
PagodNaUtak earned 1000 total points
ID: 37835671
Try something like this:

Haven't tested it so please let me know if it works.

Dim startInfo As New ProcessStartInfo
        Using p As New Process
            startInfo.FileName = "cmd.exe"
            startInfo.Arguments = "/C date 04-11-2011"
            startInfo.WindowStyle = ProcessWindowStyle.Hidden
            startInfo.WorkingDirectory = "c:\"
            startInfo.UseShellExecute = False
            p.StartInfo = startInfo
            p.Start()
            p.WaitForExit()
        End Using
0
 
LVL 3

Author Comment

by:sasllc
ID: 37835687
One simple line of code I'm trying right now is this:

Microsoft.VisualBasic.DateString = psNewDate

...with psNewDate being a string I build in the format mm-dd-yy.  If I run the program and key in a date of 03-03-03, then go to the command prompt on the scanner and key in 'Date', it shows  Monday, March 3, 2003.  And, the Date/Time icon in Control Panel shows the same.

Can it be that easy?  Or, am I missing something here?
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 37840876
>> Microsoft.VisualBasic.DateString = psNewDate

Correct me if I am wrong, with the above approach, you need administrator previledge to change the time?
0
 
LVL 3

Author Comment

by:sasllc
ID: 37840889
So far it hasn't been an issue.  Maybe it's because I'm doing it on a mobile device running Windows CE rather than a desktop computer or server??  

In my tests to far, it seems to work fine, although I do worry that I'm missing something--since no one on e-e or elsewhere that I've found has suggested this easy solution.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 19 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question