From: Nick B on
How can i use dos command line commands within a vbs script?

Situation.

I have a program that allows a command line interface. That allows for
reporting and teh execution of commands. I need to be able to read text from
a CSV file or tab sepearted file and add that data to a commmand line command
to execute commands for the application with out any intervention from an
operator.

so i basicly just need to know how to use dos command line commands within a
vbs script.

Any ideas?


--
Nick
From: McKirahan on
"Nick B" <ntbritton(a)cox.net> wrote in message
news:0587677F-24FB-4E62-88B3-E62E85ED6A8E(a)microsoft.com...
> How can i use dos command line commands within a vbs script?
>
> Situation.
>
> I have a program that allows a command line interface. That allows for
> reporting and teh execution of commands. I need to be able to read text
from
> a CSV file or tab sepearted file and add that data to a commmand line
command
> to execute commands for the application with out any intervention from an
> operator.
>
> so i basicly just need to know how to use dos command line commands within
a
> vbs script.
>
> Any ideas?

One way is to use the FileSystemObject to generate a batch file
then use te Shell object to run it.


From: Dan on
Like this?

Dim objShell: Set objShell = CreateObject("WScript.Shell")

objShell.Run "%COMSPEC% /c dir c:\windows /s /w", 1, True

WScript.Echo "Done"
From: Richard Mueller on
Nick B wrote:

> How can i use dos command line commands within a vbs script?

You can use the Run method of the wshShell object. When I run a DOS command,
I use %comspec% and the /c parameter. For example:
=====
strCmd = "%comspec% /c dir ""c:\Program files\*.exe"" > c:\temp.txt"
Set objShell = CreateObject("Wscript.Shell")
objShell.Run strCmd, 0
======
Note that quotes embedded in the string must be doubled. The second
parameter passed to the Run method dictates how the command is run, 0 means
hidden, 1 normal window, 3 minimized.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net


From: Nick B on
Using the below script it will leave windows open. One for each tape it
blanks.

How can i make it close the window?

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\program files\bakbone software\" & _
"netvault\scripts\testing\output.txt", ForReading)

Wscript.Echo vbCrLf & "VS SVDL Blank Media"

Do While objTextFile.AtEndOfStream <> True
strLine = objtextFile.ReadLine
If inStr(strLine, ",") Then
arrMediaBlank = split(strLine, ",")
Wscript.Echo vbCrLf & "medialabel: " & arrMediaBlank(0)
Wscript.Echo "group: " & arrMediaBlank(1)
Wscript.Echo "barcode: " & arrMediaBlank(2)

Dim oShell
Set oShell = WScript.CreateObject ("WSCript.shell")
strcmd = "cmd /K CD C:\program files\bakbone software\netvault\util\ &
nvblankmedia -barcode " & arrMediaBlank(2)
oShell.run "cmd /K CD C:\program files\bakbone software\netvault\util\ &
nvblankmedia -barcode " & arrMediaBlank(2)
Set oShell = Nothing
WScript.Echo strcmd
i = i + 1
End If
Loop

Wscript.Echo vbCrLf & "Number of Tapes Blanked: " & i

--
Nick


"Nick B" wrote:

> How can i use dos command line commands within a vbs script?
>
> Situation.
>
> I have a program that allows a command line interface. That allows for
> reporting and teh execution of commands. I need to be able to read text from
> a CSV file or tab sepearted file and add that data to a commmand line command
> to execute commands for the application with out any intervention from an
> operator.
>
> so i basicly just need to know how to use dos command line commands within a
> vbs script.
>
> Any ideas?
>
>
> --
> Nick