Solved

problem launching bat file from vbs script.

Posted on 2007-03-29
5
305 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
Comment Utility
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
Comment Utility
same problem unfortunately.
0
 

Author Comment

by:juliandormon
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now