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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hide dos window problem 1

Status
Not open for further replies.

R17

Programmer
Jan 20, 2003
267
PH

hi, i have this code

Code:
if file("h:\dtr\dtr.exe")=.t.
	=adir(lalocal,"c:\dtr\dtr.exe")
	=adir(laserver,"h:\dtr\dtr.exe")

	if lalocal(1,3)<laserver(1,3)
		?winexecrun(&quot;copy h:\dtr\*.* c:\dtr&quot;)
	else
		if lalocal(1,3)=laserver(1,3)
			if lalocal(1,4)<laserver(1,4)
				?winexecrun(&quot;copy h:\dtr\*.* c:\dtr&quot;)		
			endif
		endif
	endif
	
	run /n dtr.exe
else
	wait window &quot;Drive H not found on your computer! Please log on..&quot;
endif

function winexecrun
parameter ccommand

declare integer WinExec in win32api ;
	string command, integer param

retval = winexec(sys(2004) + &quot;FOXRUN.PIF /C &quot; + ccommand, 0)

clear dlls winexec

return retval

this code basically copies the latest dtr.exe from drive H to user's computer. i want to hide dos window while it is copying the files.

after i run this code, dtr.exe in C is not updated to the latest version in drive H. i'm very sure files in drive H are the new files.

pls help. TIA
 
R17

You can use the native COPY FILE command to copy the files without requiring your function winexecrun() and thus resolve the DOS window problem.

If you require confirmation that the file(s) were copied. use the WinAPI call CopyFile(), the return value from which will determine if the operation was successful or not.

The Winexec() function remains essentially for backwards compatability with 16bit O/S so suggest you replace it with ShellExecute() within your function and use it to launch dtr.exe

Keyword search will find examples of CopyFile() and ShellExecute()

File() is not as reliable as ADIR() in determining the existence of a file.

So :-

if file(&quot;h:\dtr\dtr.exe&quot;)=.t.

could be

lnNo = ADIR(laTemp,&quot;h:\dtr\dtr.exe&quot;)
IF lnNo = 1
[tab]* Code
ENDI




FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
hi Tia,

how about trying this, I got this from some of the tips here, I just cant remember who actually gave this one to me, but I hope this works for you just like it did to me.

#define SW_SHOW_HIDDEN 0
#define SW_SHOW_NORMAL 1
#define SW_SHOW_MINIMIZED 2
#define SW_SHOW_MAXIMIZED 3
oShell = createobject(&quot;WScript.Shell&quot;)
oShell.Run(&quot;Your DOS Command&quot;,SW_SHOW_HIDDEN,.T.)

so basically, just add the first 5 lines of the code to your program and substitute the winexecrun and your run with this.

like :

#define SW_SHOW_HIDDEN 0
#define SW_SHOW_NORMAL 1
#define SW_SHOW_MINIMIZED 2
#define SW_SHOW_MAXIMIZED 3
oShell = createobject(&quot;WScript.Shell&quot;)
if file(&quot;h:\dtr\dtr.exe&quot;)=.t.
=adir(lalocal,&quot;c:\dtr\dtr.exe&quot;)
=adir(laserver,&quot;h:\dtr\dtr.exe&quot;)

if lalocal(1,3)<laserver(1,3)
oShell.Run(&quot;copy h:\dtr\*.* c:\dtr&quot;,SW_SHOW_HIDDEN,.T.)
else
if lalocal(1,3)=laserver(1,3)
if lalocal(1,4)<laserver(1,4)

oShell.Run(&quot;copy h:\dtr\*.* c:\dtr&quot;,SW_SHOW_HIDDEN,.T.)
endif
endif
endif
oShell.Run(&quot;dtr.exe&quot;, SW_SHOW_HIDDEN,.T.)
else
wait window &quot;Drive H not found on your computer! Please log on..&quot;
endif
 
hi chris,

what can i do to hide the DOS window?

i used madhater2002's code but i'm having this error,

OLE error code 0x80070002: The system cannot find the file specified.

what's wrong?
 

as simple as that! thanks chris!
 
Chris has already solved your problem but given the title of this thread I will just add this FAQ just in case a member comes to this thread in the future looking for the answer.

Hide DOS Window When Runnig DOS Commands
faq184-4259

Slighthaze = NULL
[sub]craig1442@mchsi.com[/sub][sup]
&quot;Whom computers would destroy, they must first drive mad.&quot; - Anon​
[/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top