echo vbs code but errors, help

Hewlett-packard / Sd2100
May 6, 2009 at 20:14:13
Specs: Windows XP, 1024
i put @ECHO "code" >file.vbs

but it errors saying the command isnt there and such. how would do i have to do to get this to echo in a bat file to make the vbs.?

all this code is line by line in my bat but only END IF is copied to the VBS.

Sub Run(ByVal sFile)
Dim shell

Set shell = CreateObject("WScript.Shell")
shell.Run Chr(34) & sFile & Chr(34), 1, false
Set shell = Nothing
End Sub


intAnswer = _
Msgbox("Do you want to delete these files?", _
vbYesNo, "Delete Files")

If intAnswer = vbYes Then
RUN "test.bat"
Else
Msgbox "You answered no."
End If


See More: echo vbs code but errors, help

Report •


#1
May 7, 2009 at 01:43:22
Try this:

Code begins...
set vbs=file.vbs

echo Sub Run(ByVal sFile)>>%vbs%
echo Dim shell>>%vbs%
echo.>>%vbs%
echo Set shell = CreateObject("WScript.Shell")>>%vbs%
echo shell.Run Chr(34) ^& sFile ^& Chr(34), 1, false>>%vbs%
echo Set shell = Nothing>>%vbs%
echo End Sub>>%vbs%
echo.>>%vbs%
echo.>>%vbs%
echo intAnswer = _>>%vbs%
echo Msgbox("Do you want to delete these files?", _>>%vbs%
echo vbYesNo, "Delete Files")>>%vbs%
echo.>>%vbs%
echo If intAnswer = vbYes Then>>%vbs%
echo RUN "test.bat">>%vbs%
echo Else>>%vbs%
echo Msgbox "You answered no.">>%vbs%
echo End If>>%vbs%

Code ends...


Report •

#2
May 7, 2009 at 05:02:28
That worked but how do i do it with just > that errors, i dont want the box to pop up twice only be created once when >> just Amends it./

Thanks for the help


Report •

#3
May 7, 2009 at 15:50:06
Change this line:
echo Sub Run(ByVal sFile)>>%vbs%

to:
echo Sub Run(ByVal sFile)>%vbs%


Report •

Related Solutions


Ask Question