I am new to vbs and need some help. Can anyone give me a sample of how
you can call a batch file from within a .vbs script? This is going to
be used in a workgroup enviroment.

Thanks for you help and time

Jason

Re: Call a batch file from a vbs script by Scripting

Scripting
Mon Mar 14 17:53:47 CST 2005

Easy,

Dim str_host
Set objshell = CreateObject("wscript.shell")
str_host = "127.0.0.1"
objshell.exec("ping " & str_host)




"SpiritBoy" <groups@advancepcservices.com> wrote in message
news:1110837585.207814.195350@o13g2000cwo.googlegroups.com...
>I am new to vbs and need some help. Can anyone give me a sample of how
> you can call a batch file from within a .vbs script? This is going to
> be used in a workgroup enviroment.
>
> Thanks for you help and time
>
> Jason
>



Re: Call a batch file from a vbs script by Torgeir

Torgeir
Tue Mar 15 03:31:23 CST 2005

SpiritBoy wrote:

> I am new to vbs and need some help. Can anyone give me a sample
> of how you can call a batch file from within a .vbs script?
> This is going to be used in a workgroup enviroment.
Hi

I prefer to use the Run method:

'--------------------8<----------------------

sBatFile = "c:\Scripts\something.bat"

Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

If Not oFSO.FileExists(sBatFile) Then
MsgBox "Could not find batch file, quitting!", _
vbCritical + vbSystemModal, "Text search"
WScript.Quit
End If

' just in case there is spaces in the path
sBatFileShort = oFSO.GetFile(sBatFile).ShortPath

' Run the batch file hidden, and let the VBScript wait for
' the batch file to finish
oShell.Run sBatFileShort, 0, True

'--------------------8<----------------------


If there is a space in the bat, an alternative to use the
sBatFileShort:

oShell.Run """" & sBatFile & """", 0, True

(In VBScript, inside a quoted string, use two quotes to get one
effective)


WSH 5.6 documentation (local help file) can be downloaded
from here if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Call a batch file from a vbs script by SpiritBoy

SpiritBoy
Wed Mar 16 09:37:19 CST 2005

Thanks for your responses. I was able to get the second response to
work correctly. In regards to the 1st response I do not see where you
specify the name of the batch file you are trying to call.

However I now have a new problem. Our network is composed of 300
laptops that are not on a domain. Plus the users connect to the
network thru a wireless connection. The script I have setup is pulling
a batch file off the network. I have configured the local machine
policy to open the script during the login process. The script is
trying to run before the wireless connection is able to connect to the
network where the batch file is stored. Does anyone know how to delay
the call of the login.vbs or delay the call of the batch file within
the script file?

Thanks once again for your help & time

Jason


Re: Call a batch file from a vbs script by Torgeir

Torgeir
Wed Mar 16 09:46:53 CST 2005

SpiritBoy wrote:

> Thanks for your responses. I was able to get the second response to
> work correctly. In regards to the 1st response I do not see where you
> specify the name of the batch file you are trying to call.
>
> However I now have a new problem. Our network is composed of 300
> laptops that are not on a domain. Plus the users connect to the
> network thru a wireless connection. The script I have setup is pulling
> a batch file off the network. I have configured the local machine
> policy to open the script during the login process. The script is
> trying to run before the wireless connection is able to connect to the
> network where the batch file is stored. Does anyone know how to delay
> the call of the login.vbs or delay the call of the batch file within
> the script file?
Hi

Maybe go into a loop waiting for the file to show up, as the script
in this link does:

http://groups.google.co.uk/groups?selm=O8WJIwWDFHA.3020%40TK2MSFTNGP09.phx.gbl


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx

Re: Call a batch file from a vbs script by Xander

Xander
Wed Mar 16 09:52:06 CST 2005

Perhaps this works?

Wscript.Sleep 5000 '1000 x number of seconds to wait
Msgbox "this message shows 5 seconds after the start of the script."


"SpiritBoy" <groups@advancepcservices.com> schreef in bericht
news:1110987439.737899.50520@l41g2000cwc.googlegroups.com...
> Thanks for your responses. I was able to get the second response to
> work correctly. In regards to the 1st response I do not see where you
> specify the name of the batch file you are trying to call.
>
> However I now have a new problem. Our network is composed of 300
> laptops that are not on a domain. Plus the users connect to the
> network thru a wireless connection. The script I have setup is pulling
> a batch file off the network. I have configured the local machine
> policy to open the script during the login process. The script is
> trying to run before the wireless connection is able to connect to the
> network where the batch file is stored. Does anyone know how to delay
> the call of the login.vbs or delay the call of the batch file within
> the script file?
>
> Thanks once again for your help & time
>
> Jason
>



Re: Call a batch file from a vbs script by SpiritBoy

SpiritBoy
Wed Mar 16 13:23:03 CST 2005

Thanks Xander, that works perfect!!!

Jason