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

Command.Run(cmd) execution step

Status
Not open for further replies.

w33mhz

MIS
May 22, 2007
529
US
I have an issue where I am running an executable from within a vbscript that does some more advanced processing of the file. What I would like to know is does the script wait until the execution is completed before going to the next step of the script (i.e. fso.DeleteFile objFile.Name).

Code:
For Each objFile in colFiles
	Set fso = CreateObject ("Scripting.FileSystemObject")
	GetFile = Split(fso.OpenTextFile (objFile.Name).ReadAll,vbCr)
	TempFile = objFile.Name & ".tmp"
	Set fw = fso.CreateTextFile (TempFile, ForWriting, True)
	i = 0
	For Each strLine in GetFile
		i = i + 1
		'Wscript.Echo i & " " & strLine
		If i > 8 Then
			'Wscript.Echo strLine
			fw.WriteLine strLine
		End if
	Next	
	fw.Close
	fso.MoveFile TempFile , "E:\temp\" & objFile.FileName & ".csv"
	Command.Run(cmd)
	fso.DeleteFile objFile.Name	
Next

Windows Haiku:

Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
 
And waht is Command.Run? Is that WScript.Shell?

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Command.Run cmd, 2, True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
@markdmac
It is a .Net C# console app

@PHV
Are those the additional parameters that I should use to make sure the script waits for the executable to finish?

Windows Haiku:

Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
 
@markdmac
yes it is a Wscript.Shell object I appologize I was just hoping everyone would make that assumtion.

Windows Haiku:

Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
 
Thx PHV I finally found the page I was looking for that verifies your syntax

Windows Haiku:

Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top