Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 11-13-2017, 07:23 AM
ShaunVW ShaunVW is offline
Member
 
Join Date: Feb 2012
Posts: 45
Default ShellExecute to pipe "net time"

Good day
Please can someone help me to figure out the command to use?
I currently have

Code:
ShellExecute(Handle, 'open', 'net time \\pdc-fs >c:\ProductionDB\servertime.txt',nil,nil,SW_HIDE);
I am getting a return value of 2 though.
What I am wanting to do is get the time from our server and dump it into a file.
Any help is appreciated, thank you.
Reply With Quote
  #2  
Old 11-13-2017, 08:31 AM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,218
Default

ShellExecute expects the parameters in the 4th parameter
I would try something like
Code:
ShellExecute(Handle, 'open', 'net.exe','time \\pdc-fs >c:\ProductionDB\servertime.txt',nil,SW_HIDE);
Reply With Quote
  #3  
Old 11-13-2017, 08:50 AM
ShaunVW ShaunVW is offline
Member
 
Join Date: Feb 2012
Posts: 45
Default

Thank you.
I now get a return of 42 (which is >32, so apparently successful), but still no file appearing in the folder...?
Reply With Quote
  #4  
Old 11-13-2017, 11:08 AM
ShaunVW ShaunVW is offline
Member
 
Join Date: Feb 2012
Posts: 45
Default

It seems this might be by design, see https://connect.microsoft.com/Visual...edirected-file

Instead, must use the following, and this works
Code:
ShellExecute(Handle, 'open', 'cmd.exe','/C net time \\pdc-fs >c:\ProductionDB\servertime.txt',nil,SW_HIDE);
Reply With Quote
  #5  
Old 11-13-2017, 01:10 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,218
Default

ok, didn't know that.
Glad it works now and thank you for providing the solution
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 10:03 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.