Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with VB Script Error

Status
Not open for further replies.

scotto5555

Technical User
Jun 29, 2004
3
GB
The script below is to change the system time on a touch screen to the new time specified in the variable new time when the script is executed.

When I run a script I get an error message : Expected End of statement.

Error occurred in statement :' set oshell = CreateObject ("Wscript.shell") oshell.run "cmd /K time " & Cstr(newtime) & " & exit""

The full script is below:

dim newtime
dim oshell
newtime = Cstr (Hour.Value)& ":" & Cstr (Min.Value)& ":" & Cstr (Second.Value) 'newtime will contain a value in format HH:MM:SS set oshell = CreateObject ("Wscript.shell") oshell.run "cmd /K time " & Cstr(newtime) & " & exit"
set oshell = Nothing

Any help would be appreciated.

Thanks
 
What about this ?
Code:
dim newtime
dim oshell
newtime = Cstr (Hour.Value)& ":" & Cstr (Min.Value)& ":" & Cstr (Second.Value) 'newtime will contain a value in format HH:MM:SS 
set oshell = CreateObject ("Wscript.shell") 
oshell.run "cmd /K time " & Cstr(newtime) & " & exit"
set oshell = Nothing

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
So just need to split the line that is giving the error into two separate lines ?

Ok makes sense.

Will try this out on the system over the next few days and see if this works.

It will be the end of the week probably before I can report back if it works.

Thanks
 
Just tried the code in my system but now comes up with different error:
ActiveX component can't create object:'Wscript.shell'

This is running on Windows CE.NET v5.00 on a touch screen system.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top