473,324 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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 4374
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

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

Similar topics

13
by: jenny | last post by:
Hi, I am trying to find a VB way that would create a folder on all existing drives - the folder name would be the same on each drive. ie c:\backup, d:\backup, etc. But the folders would only be...
1
by: J P Singh | last post by:
Hi All I want to create a webpage which will list all the files in particular folder and hyperlink to them to allow users to view the grpahics online without having to send each file to them by...
8
by: mcmg | last post by:
Hi, I have an asp app that works fine on a windows xp machine but does not work on a windows 2000 server. I have the following code in my global.asa: <OBJECT RUNAT=Server SCOPE=SESSION...
15
by: Carlos Lozano | last post by:
Hi, What is the right way to create an OCX COM component. The component is already registerred, but can't create an instance. I am using the reference to the interop module created. If I use...
6
by: Julien | last post by:
Hello, I have some files located in a file server and managed by a SQL database from a web based interface using ASP + VBSCRIPT technology. I need to automatically copy those files to a web...
3
by: TyBreaker | last post by:
I have a vbscript which returns the folder size of any folder instantly by referring to Folder.Size. I don't need any iteration or recursion through the subfolders, adding together individual file...
8
by: Paw | last post by:
Greetings. I use asp. what I need is is when a visitor comes to the site, I need it to check the host name. if "www.hometowndigest.com" is the host, then check a folder named "something" and if...
10
by: brooksr | last post by:
I know VB5/VBA very well but have not used VB to create web pages but need to do so. Can someone explain the purposes and differences between VBScript and VB.NET to create web pages? Also...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.