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

Author Topic: Can anone help on Windows .BAT Filescc/ VB scripts  (Read 5235 times)

0 Members and 1 Guest are viewing this topic.

shreked

    Topic Starter


    Rookie

    • Experience: Familiar
    • OS: Windows 7
    Can anone help on Windows .BAT Filescc/ VB scripts
    « on: April 21, 2018, 11:56:46 AM »
    Hi there

    Im trying to run a command using a VB script  but need help finishing off if anyone can help as I aint got a clue how to do it  ???

    I have this command  that creates a new folder in C :\CCTV DOWNLOADS\DownLoad of which shown below.

    What im trying to do then is to 7 ZIP the new folder .

    I think that its a VB Script that I need but if there an easier way it would be greatly appriciated.  Is there anyway I can run a VB script or .BAT file without running as an administrator?


    Thanks
    Option Explicit

    Const strDLFolder = "C:\CCTV DOWNLOADS\DownLoad"
    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("COMPASS REF NO", 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.Run "explorer.exe /select,""" & objFSO.BuildPath(strDLFolder, strNewFolder) & """"