Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Keep getting Variable is undefined.bat error anyone got any ideas why?  (Read 3207 times)

0 Members and 1 Guest are viewing this topic.

tweacle

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 7
    Hi 

    I have a .VBS script and a .bat file that im trying to run together.

    Ive got this script that suppoused to  runs the VBS script and then open the .BAT file.

    I keep getting the error variable is undefined .bat error come up when trying to run it. Can anyone help.

    Thanks

    Option Explicit
    Const strDLFolder = "C:\Downloads"
    Dim objFSO, objWShell, objDLFolder, strNewFolder, objFile
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objWShell = CreateObject("WScript.Shell")

    If Not objFSO.FolderExists(strDLFolder) Then objFSO.CreateFolder(strDLFolder)
    objWShell.CurrentDirectory = strDLFolder
    Set objDLFolder = objFSO.GetFolder(strDLFolder)
    If objDLFolder.Files.Count = 0 Then WScript.Quit
    Do
    Err.Clear
    strNewFolder = InputBox("Folder Name", vbLf & "Enter the name of the folder to be created:")
    If strNewFolder = False Then WScript.Quit
    On Error Resume Next
    objFSO.CreateFolder strNewFolder
    Loop While Err.Number <> 0 Or Not objFSO.FolderExists(strNewFolder)
    On Error Goto 0
    For Each objFile In objDLFolder.Files
    objFSO.MoveFile objFile.Name, strNewFolder & "\"
    Next
    objWShell.Popup "All files moved.", 0, "Done", vbInformation Or vbSystemModal Or &h00040000&
    dim dotbat
    set dotbat=createobject("wscript.shell")
    dotbat.Run "C:\Desktop\testersnew.bat", 1, True
    set dotbat=Nothing

    and ive also tried the command below too in the middle.

    dotbat.Run "cmd /C C:\Desktop\testersnew.bat", 1, True
     

    Allan

    • Moderator

    • Mastermind
    • Thanked: 1260
    • Experience: Guru
    • OS: Windows 10
    I'm locking this thread and closing your tweacle account. You already have an active account on this site with the username shreked. One account per customer Mr. Masters.