Solved

How to change or update the system date using vb?

Posted on 2012-04-11
7
494 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 48

Accepted Solution

by:
Mikal613 earned 250 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 8

Assisted Solution

by:PagodNaUtak
PagodNaUtak earned 250 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator (https://www.appcelerator.com/). This article presumes a wor…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now