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

how to run a cmd program from HTA? 3

Status
Not open for further replies.

barny2006

MIS
Mar 30, 2006
521
US
Hi,
i have an hta program that backs up files from c: drive to a cd. i have finished all the components of the hta, inputs, drives, file selections, etc. but the cd copy command is a dos app that runs from the command prompt. this command runs from vbs but when i imbed the vb script in the hta, it doesn't run. the cmd screen flashes and goes away, instead of staying and displaying the dos command and the results of the copy.
here's what i have tried:
Code:
wshshell.Run("cmd.exe /c createcd.exe d: c:\folder\file.txt")
it doesn't work
then i tried this:
Code:
Set wseExternal = wshShell.Exec("wscript.exe //NOLOGO xxx.vbs")
xxx.vbs is the program that runs the same command that didn't work in the above.
if i run xxx.vbs by itself, it works.
any ideas how to get around this?
thanks




 
thanks ph,
i've tried the null char to split the files. but the files just aren't there. i displayed the whole string as you can see on the code. but as dm says, all the examples that they have, is in vb6. and it may involve registering a dll or something. i appreciate you all's help on this. the code that dm advised me on, works. but my intellectual curiosity wants to find out if this method would work or not. and if not, why.
thanks again.
 
I tried mixing and matching all those possible flags about a day ago and some seem to work and some do not. Looking at it through an object browser it looks like it has several properties and methods that just aren't exposed to vbscript. I'm guessing this ability may be one of them. Anyway, the dll that comes with PrimalScript is called FileDialog.dll located under "Program Files\Common Files\SAPIEN Common". It gets installed and registered automatically, but it can function on it's own from a test I tried. If you don't use PrimalScript, you can always test drive it for 30 days .

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
dm4ever did you happen to give it a try on Vista?

I am wondering if anyone has come up with a solution what will work on a Vista machien out of the box without having to add DLL files. So far my searching has come up empty. I typically don't find a need for selecting multiple files, just a single one but looks like all the known methods were removed from Vista.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
mark, dm,
thanks so much.
dm, i think you're right. this mix mode may not work on vb script and only works with vb 6. so, i sent an email to the scripting guys and they referred me to "bug report department". i'm waiting for an answer. i'll post the result.
thanks everybody again.
 
Mark,
I have not tried any of this on Vista so I'm not sure what works or what doesn't on that system.

Barny,
No problem. I enjoy these forums because they help me learn and try new things so you've helped me a lot in that respect.

For those that may want to give that dll a try, here's the code that will use it. I've only tested this on WinXP.

Code:
' ====================================================================================
' Browse Multiple Files using PrimalScript's FileDailog.dll
' ====================================================================================
Set objFileDial = CreateObject("Primalscript.FileDialog")
objFileDial.AllowMultiSelect = True
objFileDial.Title = "Browse For Multiple Files"
objFileDial.FileOpenDialog
intCount = objFileDial.NumFilesSelected
For i = 0 To intCount - 1
	WScript.Echo objFileDial.SelectedFiles(i)
Next

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Well if you have Visual Studio 6.0 you can do it.

The trick involves creating a License Package for the Common Dialog control. Then you include the .LPK file and COMDLG32.CAB with your HTA, and reference both of these properly using <OBJECT> tags.

This gives you access to everything you'd have in a VB6 program. The issue would be that you can't distribute the .LPK file except as part of an application (even an HTA application qualifies). It's not legal to pass these files around for others to use in their HTAs though.

As far as I can tell the object exposed by the User Manager Control Panel applet in WinXP (UserAccounts.CommonDialog) is broken. From what I see if you use multiselect with it, it truncates at the first vbNullChar when it converts the results back to a String. So the .FileName property only gives you back the directory, not the list of selected files (unless you select just one of course).
 
The method I described works with Win95 through WinXP. Should work fine with Vista too, though I haven't been able to test it.
 
dilletante,
i think you're right on the money. that's a very
good analysis of the problem that dm, mark and myself
have tried to solve since last week. this app that
i'm developing is for internal use only and for our
data entry people to back up multi files.
i appreciate everyone's help, specially dm. let's see
what MS has to say about this. i got a reply back from
the "bug department" asking for specs on the problem
and the product.
thanks again, guys.
cheers.
 
dilletante,
how does this method work? i have cmdlg32.dll
and cmdlg32.ocx in my windows\system32 directory.
do i need to install visual studio 6.0 or what?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top