Solved

problem launching bat file from vbs script.

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
batch script 3 45
Writing lines of code from a form output in script within a results page 2 23
Use GPO script to report finding a certain file 16 15
BATCH to EXE Converter 2 35
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…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

861 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