svendickman
asked on
vbscript WSH run external commands in the same window
When I run the following script it will always open a new window to run the external command wget.
If I use the objShell.Exec command it runs without opening a new window but the status of the command is not displayed.
Set objShell = WScript.CreateObject("WScr ipt.Shell" )
For tens = 0 to 1
for ones = 1 to 9
objShell.run "wget -v http://test.com/file" & tens & ones & ".mp3",10,True
next
Next
As an added bonus is there a better way to count with leading zeros?
And finally, is there a better group to pose this kind of question?
If I use the objShell.Exec command it runs without opening a new window but the status of the command is not displayed.
Set objShell = WScript.CreateObject("WScr
For tens = 0 to 1
for ones = 1 to 9
objShell.run "wget -v http://test.com/file" & tens & ones & ".mp3",10,True
next
Next
As an added bonus is there a better way to count with leading zeros?
And finally, is there a better group to pose this kind of question?
lol, it said it sumbitted the first half when I went to get that link, not i got the last half missing the top? well just in case it does not surface in somewhere, i'll rewrite it again.
First: try ",0,True" instead of ",10,True" at the end of your run method.
That value indicates intWindowStyle Which can be one of the following:
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application.
Enjoy,
2K
(\o/)
First: try ",0,True" instead of ",10,True" at the end of your run method.
That value indicates intWindowStyle Which can be one of the following:
0 Hides the window and activates another window.
1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order.
7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
10 Sets the show-state based on the state of the program that started the application.
Enjoy,
2K
(\o/)
Of course, I can't leave the middle untouched, although this is not necessarily better, here's two alternate ways of counting: The shorter insures num is always wrong, yet usable. The longer insures continual kluge on re-use.
For num = 101 to 119
objShell.run "wget -v http://test.com/file" & right(num,2) & ".mp3",0,True
Next
For num = 1 to 19
objShell.run "wget -v http://test.com/file" & right("0" & num,2) & ".mp3",0,True
Next
For num = 101 to 119
objShell.run "wget -v http://test.com/file" & right(num,2) & ".mp3",0,True
Next
For num = 1 to 19
objShell.run "wget -v http://test.com/file" & right("0" & num,2) & ".mp3",0,True
Next
ASKER
Hello K_2K
Your padded counting method are good. But the intWindowStyle option still opens a new window. I am hoping to have an output similar to what a batch file would give, thus showing the progress of each wget command in the same window.
Thanks, Sven
Your padded counting method are good. But the intWindowStyle option still opens a new window. I am hoping to have an output similar to what a batch file would give, thus showing the progress of each wget command in the same window.
Thanks, Sven
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www-tcsn.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/
was where i thought these types of questions might be found, but they sometimes seem to be stuck in the "paid for Visual Studio" mode as apposed to the "quick and easy VB-script" mode.
Maybe Since Java Script has it's own area we should ask about VB Script? Frankly, the real programmers laugh at me i'm sure, but with no run-time addons, no value added costs, and fewer issues than most other languages, VB-script does a LOT more than batch with little or no extra investment of money, and time to learn.
My 2¢,
2K
(\o/)