468,768 Members | 1,708 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,768 developers. It's quick & easy.

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="VBScript">
<!--
Option Explicit
Dim objFSO, objFolder, strDirectory
strDirectory = "c\testing"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder(strDirectory)
alert("strDirectory")
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
Oct 29 '08 #1
5 4103
jg007
283 100+
I am not sure why you have used -

'<SCRIPT LANGUAGE="VBScript">
<!--'

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("strDirectory"') '
Oct 29 '08 #2
jg007
283 100+
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Create Directory Test</TITLE>
  5. </HEAD>
  6. <BODY>
  7. <CENTER>
  8. <H3> Create Directory Test</H3>
  9. <FORM NAME="frmMyForm">
  10.    <INPUT TYPE=label  NAME="CompletionText">
  11.    <INPUT TYPE=button VALUE="Run Script" NAME="btnDir">
  12. </FORM>
  13. <SCRIPT LANGUAGE="vbscript">
  14.  
  15.         Dim objFSO, objFolder, strDirectory   
  16.  
  17.         Sub btnDir_OnClick
  18.      strDirectory = "c:\testing"
  19.     Set objFSO = CreateObject("Scripting.FileSystemObject")
  20.     Set objFolder = objFSO.CreateFolder(strDirectory)
  21.     alert(strdirectory)    
  22.     frmMyForm.CompletionText.value =  "Just created " & strDirectory
  23.  
  24.     End Sub
  25. </SCRIPT>
  26. </BODY>
  27. </HTML>
  28.  
  29.  
Oct 29 '08 #3
I am not sure why you have used -

'<SCRIPT LANGUAGE="VBScript">
<!--'

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("strDirectory"') '
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..
Oct 29 '08 #4
jg007
283 100+
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
Oct 29 '08 #5
jg007
283 100+
this is also a Brilliant reference and opens as a windows helpfile so is fully searchable

http://www.microsoft.com/downloads/d...displaylang=en
Oct 29 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by J P Singh | last post: by
15 posts views Thread by Carlos Lozano | last post: by
3 posts views Thread by TyBreaker | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.