creating folder using vbscript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • meenu_susi
    New Member
    • Jun 2006
    • 47

    creating folder using vbscript

    hi all

    Could you please help me out i creating folder using vbscript..

    I have used the following code...


    <SCRIPT LANGUAGE="VBScr ipt">
    <!--
    Option Explicit
    Dim objFSO, objFolder, strDirectory
    strDirectory = "c\testing"
    Set objFSO = CreateObject("S cripting.FileSy stemObject")
    Set objFolder = objFSO.CreateFo lder(strDirecto ry)
    alert("strDirec tory")
    WScript.Echo "Just created " & strDirectory
    WScript.Quit

    </script>

    and i am getting the following error..

    Expected statement
    800A0400
    Microsoft VBScript compilation error

    thanks in advance

    reagrds
    meenu
    Last edited by meenu_susi; Oct 29 '08, 05:00 AM. Reason: URGENT
  • jg007
    Contributor
    • Mar 2008
    • 283

    #2
    I am not sure why you have used -

    '<SCRIPT LANGUAGE="VBScr ipt">
    <!--'

    this is not normally needed for a vbs file that is ran on the pc are you trying to run this from a webpage as I receive the same error as you when trying to use this code in a .vbs file then trying to run it

    also you have missed out a ":" from "c:\testing " and I am not sure what you are trying to do with ' alert("strDirec tory"') '

    Comment

    • jg007
      Contributor
      • Mar 2008
      • 283

      #3
      as you might have guessed I don't do much webpage coding but looking at the code you have I have pieced together some code that you can put into a .html file if that is what you are trying to do but please note that there is no testing to see if the directory exists so nothing will happen if it is already there

      Code:
      <HTML>
      <HEAD>
      <TITLE>Create Directory Test</TITLE>
      </HEAD>
      <BODY>
      <CENTER>
      <H3> Create Directory Test</H3>
      <FORM NAME="frmMyForm">
         <INPUT TYPE=label  NAME="CompletionText">
         <INPUT TYPE=button VALUE="Run Script" NAME="btnDir">
      </FORM>
      <SCRIPT LANGUAGE="vbscript">
      
              Dim objFSO, objFolder, strDirectory   
       
              Sub btnDir_OnClick
       	strDirectory = "c:\testing"
      	Set objFSO = CreateObject("Scripting.FileSystemObject")
      	Set objFolder = objFSO.CreateFolder(strDirectory)
      	alert(strdirectory)	
      	frmMyForm.CompletionText.value =  "Just created " & strDirectory
      
          End Sub
      </SCRIPT>
      </BODY>
      </HTML>

      Comment

      • meenu_susi
        New Member
        • Jun 2006
        • 47

        #4
        Originally posted by jg007
        I am not sure why you have used -

        '<SCRIPT LANGUAGE="VBScr ipt">
        <!--'

        this is not normally needed for a vbs file that is ran on the pc are you trying to run this from a webpage as I receive the same error as you when trying to use this code in a .vbs file then trying to run it

        also you have missed out a ":" from "c:\testing " and I am not sure what you are trying to do with ' alert("strDirec tory"') '
        I have saved in file in notepad as a .htm file ..actually i want a folder to be created automatically using the vbscript..

        can you send me the code for proceeding further..

        Comment

        • jg007
          Contributor
          • Mar 2008
          • 283

          #5
          a .vbs file is sort of a more powerful version of a batch file in that it is text based but you can do many of the things that you can do using visual basic and it is created as a standard text file but given the extension .vbs

          you can run it either by using the file name from a command prompt or by clicking on it, if you want it to be totally command line based you can use Cscript <Name of file.vbs> from the command prompt

          if you don't want to run it from a HTML file the code is pretty much the same as you posted although I don't believe that you can use the alerter command and there is no need for the 'script' stuff

          you need to try this yourself but for more information on vbs files I would recomend that you look at microsoft's script page -

          Script centre

          &

          Scripting: Your First Steps

          Comment

          • jg007
            Contributor
            • Mar 2008
            • 283

            #6
            this is also a Brilliant reference and opens as a windows helpfile so is fully searchable

            Comment

            Working...