Solved

problem launching bat file from vbs script.

Posted on 2007-03-29
5
306 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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 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

19 Experts available now in Live!

Get 1:1 Help Now