Solved

problem launching bat file from vbs script.

Posted on 2007-03-29
5
307 Views
Last Modified: 2010-04-16
I'm trying to fire a bat file from within a vbs file - I see that cmd.exe launches in task manager, but it does not execute. I'm not sure how to debug this either.

The bat file runs flawlessly on its own.

Here's the vbs:

OPTION EXPLICIT
dim websites
dim websitearray
Dim i
Dim domain
Dim wshell


websites = "dmooreartist.com artist1111.com"


websitearray = split(websites," ")

For i = 0 to ubound(websitearray)
changethedns(websitearray(i))
Next

SUB changethedns ( domain )
WScript.Echo domain

set wshell = createobject("wscript.shell")
wshell.run "%comspec% /c C:\Documents and Settings\Administrator\Desktop\myIISScripts\changedns.bat "  & domain, 0, True
set wshell = nothing

END SUB
0
Comment
Question by:juliandormon
  • 3
  • 2
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18818025
Change this line:

wshell.run "%comspec% /c " & chr(34) & "C:\Documents and Settings\Administrator\Desktop\myIISScripts\changedns.bat " & chr(34)  & domain, 0, True
0
 

Author Comment

by:juliandormon
ID: 18818214
same problem unfortunately.
0
 

Author Comment

by:juliandormon
ID: 18818225
is there a way to loop through my array in a bat file? instead of looping in the vbs? this would also get the job done if possible, though I have no idea of how to accomplish this.
0
 

Author Comment

by:juliandormon
ID: 18818281
Thanks I can actually do this by calling the cmds directly that are found in the BAT file.
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
ID: 18818577
Sure, something like:

For %%a in (dmooreartist.com artist1111.com) do call :changethedns %%a
goto :eof

:changethedns
"C:\Documents and Settings\Administrator\Desktop\myIISScripts\changedns.bat " %1

REM You might also change the above to simply
"%userprofile%"\desktop\myIISScripts\changedns.bat " %1
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question