Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running at batch with some parameters from VB Script 1

Status
Not open for further replies.

ironpawz

IS-IT--Management
Oct 8, 2002
44
NZ

Thanks to some ppl I now can create a batch file from a VBscript containin " ^ ' etc.

I can run it also using

Set WShell = CreateObject("WScript.Shell")
WShell.Run "c:\temp\audit.bat"

I set two parameters earlier using

strInputA=InputBox("What IP Address or machine name do you want logs from?",strTitle,"IP Address")
strInputB=InputBox("What is the Admin Password?",strTitle,"Password")

and I want to feed them to the batch file as parameters I tried

Set WShell = CreateObject("WScript.Shell")
WShell.Run "c:\temp\audit.bat strInputA strInputB"

and also

WShell.Run "c:\temp\audit.bat" & strInputA & strInputB & " "

on the first one it feeds strInputA literally (no suprises) on the second I think it sees it as another command to run (cannot find file specified)
 

In answer to my post seeing as I am creating the batch file I just pushed the info into it. This does contain the admin password though so I'd rather not leave it on a system (guess I'll have to delete the file).

I'd still be interested in any answers though as would anyone else getting here coz there after the same question.

vbscript so powerful and yet so lacking! If it wasn't for the graphical prompts (my helpdesk are scared of dos) it would be easier for most things in good old dos!
 
The only problem I can see with this is that it
will result in

WShell.Run "c:\temp\audit.bat" & strInputA & strInputB & " "

Audit.bat192.168.0.1password

Try
WShell.Run "c:\temp\audit.bat " & strInputA & " " & strInputB & " "

this way you will end up with
Audit.bat 192.168.0.1 password

this will not work as strinputa and strinputb are variables and will be treated literally within quotes
WShell.Run "c:\temp\audit.bat strInputA strInputB"

Regards
Steve Friday
 
WShell.Run "c:\temp\audit.bat " & strInputA & " " & strInputB & " "

I did try this but shell seemed to treat this as three commands I got a message like "could not find password (which was one of the variables). So I assume dos was trying to execute the options as individual commands like if in dos I issued

c:\audit.bat & 10.0.0.1 & password
verses

audit 10.0.0.1 password
 
Try the following


Dim wsh
Set wsh = Wscript.CreateObject("Wscript.Shell")
strinputa = "10.1.1.2"
strinputb = "Password"
wsh.run("CMD /K c:\test.bat " & strinputa & " " & strinputb)

in test.bat I had
Echo On
Echo %1 %2

Regards
Steve Friday
 

Yes that is spot on thanks. I had put all the variables into the batch file for what I was doing but this is still greate as I know I'll use that a lot (much easier).

Good thread too for those looking for this answer. I'm saving a copy in my VBScript docs area.

Thanks Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top