Solved

How to change or update the system date using vb?

Posted on 2012-04-11
7
495 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
I recently asked a question (http://www.experts-exchange.com/Programming/Smartphones/Android/Q_28684946.html) about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

775 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