Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Run command works in command window but not in a program
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01439658
Message ID:
01439663
Views:
72
>I have a run command - automating 7zip that typed in the command window works, but when added to program fails
>the string in the command window is
>
>run '7z e -y zipfile.zip'
>
>in the program it is a little different
>lcZipString='7z e -y zipfile.,prg'
>run (lzZipString)
>
>
>The command window opens for a second and then closes.
>
>Any ideas?
>Mike

Try also
************************************************************
*  PROCEDURE RunShellScript()
************************************************************
*  Calling Samples...:
*  Parameter List....: tcCommand, tlSilentMode, tcRetVal
*  Major change list.:

procedure RunShellScript
lparameters tcCommand, tlSilentMode, tcRetVal

if empty(m.tcCommand)
	return
endif

local oShell, llError, loException, lnErrorCode
llError = .f.
try
	oShell = createobject("WScript.Shell")
catch to loException
	if m.tlSilentMode
		tcRetVal = "Run-time error: WScript.Shell Object is not Found"
	else
		=messagebox("Run-time error: WScript.Shell Object is not Found")
	endif
	llError = .t.
endtry
if m.llError <> .t.
	try
		lnErrorCode = oShell.run(m.tcCommand, 0,.t.) && SW_SHOW_HIDDEN 0,SW_SHOW_NORMAL 1,SW_SHOW_MINIMIZED 2,SW_SHOW_MAXIMIZED 3
		if m.lnErrorCode <> 0
		   tcRetVal = "Error in running shell command. Error Code: " + transform(m.lnErrorCode)
		endif   
	catch to loException
		if m.tlSilentMode
			tcRetVal = "Run-time error: WScript.Shell: " + ;
				m.tcCommand + chr(13) + chr(10) + Log_Error(m.loException)
		else
			=messagebox("Run-time error: WScript.Shell: " + m.tcCommand)
		endif
		llError = .t.
	endtry
endif
release oShell

return !m.llError
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform