Convert .bat file to .vbs format

Hello Experts,

I need to convert the following .bat file to a .vbs format

 
"c:\python25\python.exe" "c:\python25\check_esxi_hardware.py" -H 192.168.0.15 -U root -P file:"c:\python25\host_pass.txt" -V auto

Open in new window


Could some please give me a hand with this? I am a novice at scripting :)
JohnnyD74Asked:
Who is Participating?
 
Bill PrewCommented:
Here's the basic idea.  This will run that EXE and wait for it to finish.  More info on the Run method here:

http://msdn.microsoft.com/en-us/library/d5fk67ky%28VS.85%29.aspx

Set objShell = WScript.CreateObject("WScript.Shell")

strCommand = Quote("c:\python25\python.exe") & " " & Quote("c:\python25\check_esxi_hardware.py") & " -H 192.168.0.15 -U root -P file:" & Quote("c:\python25\host_pass.txt") & " -V auto"

objShell.Run(strCommand, 1, True)

' Add surrounding double quotes to a string
Function Quote(s)
   Quote = Chr(34) & s & Chr(34)
End Function

Open in new window

~bp
0
 
JohnnyD74Author Commented:
Thanks Bill!

It worked perfectly except for an error I got suggesting I needed to remove the parenthesis from line 5. I did so and it is working perfectly now!

Thanks Again,

John
0
 
Bill PrewCommented:
Ah yes, I often forget the subtle difference when calling a function using a return code, versus not.  Glad you sorted that out, and this was useful.

~bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.