Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista Tutorial - run 2 dos commands using vbScript as a single command

Reply
 
Old 09-05-2008   #1 (permalink)
karsagarwal
Guest


 
 

run 2 dos commands using vbScript as a single command

Hi,
I am trying to change the directory and then run another command all
in 1 line. But for some strange reason I can't even get the first
command to work. I need help!!

SA


Here's the code
===========
dim objShell
dim inFile, outFile, projFile,folderC ,cmd1,cmd2

'setting variuos paths
folderC ="C:\temp\Projects\21038Ax1aDx"
inFile = "C:\Documents and Settings\smitha\My Documents\BOM
\partlist.ini"
outFile = "out.lst"
projFile = "10297200"

'2 commands
cmd1= "cd folderC"
cmd2="partlist projFile -input inFile -outFile outFile"

set objshell = createobject("Wscript.shell")
objshell.Run "%compsec% /k cmd1 & cmd2"

My System SpecsSystem Spec
Old 09-05-2008   #2 (permalink)
Pegasus \(MVP\)
Guest


 
 

Re: run 2 dos commands using vbScript as a single command


<karsagarwal@xxxxxx> wrote in message
news:f32b7bf8-f730-416d-82d6-9064066febff@xxxxxx
Quote:

> Hi,
> I am trying to change the directory and then run another command all
> in 1 line. But for some strange reason I can't even get the first
> command to work. I need help!!
>
> SA
>
>
> Here's the code
> ===========
> dim objShell
> dim inFile, outFile, projFile,folderC ,cmd1,cmd2
>
> 'setting variuos paths
> folderC ="C:\temp\Projects\21038Ax1aDx"
> inFile = "C:\Documents and Settings\smitha\My Documents\BOM
> \partlist.ini"
> outFile = "out.lst"
> projFile = "10297200"
>
> '2 commands
> cmd1= "cd folderC"
> cmd2="partlist projFile -input inFile -outFile outFile"
>
> set objshell = createobject("Wscript.shell")
> objshell.Run "%compsec% /k cmd1 & cmd2"
Replace the line
objshell.Run "%compsec% /k cmd1 & cmd2" with this line:
wscript.echo "%compsec% /k cmd1 & cmd2"

and you will immediately see that the command cannot possibly run, because
"cd folderC" gets lumped together with "partlist".

You probably have a second problem too. Where is the command processor
supposed to find "partlist"? In the current folder? What is the current
folder? In scripts you MUST state the drive, folder, file name and
extension!


My System SpecsSystem Spec
Old 09-05-2008   #3 (permalink)
karsagarwal
Guest


 
 

Re: run 2 dos commands using vbScript as a single command

On Sep 5, 10:28*am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> <karsagar...@xxxxxx> wrote in message
>
> news:f32b7bf8-f730-416d-82d6-9064066febff@xxxxxx
>
>
>
>
>
Quote:

> > Hi,
> > I am trying to change the directory and then run another command all
> > in 1 line. But for some strange reason I can't even get the first
> > command to work. I need help!!
>
Quote:

> > SA
>
Quote:

> > Here's the code
> > ===========
> > dim objShell
> > dim inFile, outFile, projFile,folderC ,cmd1,cmd2
>
Quote:

> > 'setting variuos paths
> > folderC ="C:\temp\Projects\21038Ax1aDx"
> > inFile = "C:\Documents and Settings\smitha\My Documents\BOM
> > \partlist.ini"
> > outFile = "out.lst"
> > projFile = "10297200"
>
Quote:

> > '2 commands
> > cmd1= "cd folderC"
> > cmd2="partlist *projFile -input inFile -outFile outFile"
>
Quote:

> > set objshell = createobject("Wscript.shell")
> > objshell.Run "%compsec% /k cmd1 & cmd2"
>
> Replace the line
> objshell.Run "%compsec% /k cmd1 & cmd2" *with this line:
> wscript.echo "%compsec% /k cmd1 & cmd2"
>
> and you will immediately see that the command cannot possibly run, because
> "cd folderC" gets lumped together with "partlist".
>
> You probably have a second problem too. Where is the command processor
> supposed to find "partlist"? In the current folder? What is the current
> folder? In scripts you MUST state the drive, folder, file name and
> extension!- Hide quoted text -
>
> - Show quoted text -
Partlist command works from anywhere in the cmd window. But this needs
to be in the directory just for the -input attribute to work correctly
as it is a custom program.

I tested this exact command in the cmd window with "&" and it works
fine. I am perplexed as to how to solve this problem.

SA
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
I need to Call this command in a vbscript VB Script
Output XML to Single Line Log File using VBScript VB Script
Powershell Wrapper Script Problems - Trying to Call PowershellExchange 2007 Commands from Secondary Language (Like VBScript) PowerShell
Equivalent of powershell to vbscript command PowerShell
Where is the help for command line commands? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46