Solved

How to change or update the system date using vb?

Posted on 2012-04-11
7
493 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
Comment Utility
0
 
LVL 3

Author Comment

by:sasllc
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 8

Assisted Solution

by:PagodNaUtak
PagodNaUtak earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
>> 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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

8 Experts available now in Live!

Get 1:1 Help Now