473,231 Members | 1,870 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,231 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 4370
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.