hello everyone my name is Eric, im having a problem with a script i am trying to write for my administrative scripting class. yes this is a school project, and no i dont want anyone to write it for me i would like to learn what i am doing wrong and how to fix it. i have done large amounts of research and cannot find a solution to my problems. so i am seeking help here.
here are the requirements for my project:
Create a script that includes the following:
' Header information
'
'========================================================
'
' File Name: IST321_EWalker_MidTerm.vbs
' This is a VBS script to run change the extention to .vbs
'
' Author: Eric Walker
' Date: July 7, 2011
'
'========================================================
option explicit
'on error resume next
dim TimeStart 'variable for time script started
dim TimeEnd 'variable for time script ends
dim TimeRan 'variable for total time script ran
dim FolderName 'variable for foldername
dim LocalDrive 'variable for c:
'dim CreateFolder 'variable
dim foldercount 'variable for folder counting
dim FolderInput 'variable for the number of folders the user wishes to create
dim folderamount 'variable for folderinput
dim filearray 'variable for array to store information about the files created
dim FolderLocation 'variable for the location of where the folders will be created.
dim textdocument 'variable for the text document that will be created in each new folder
dim sleep 'variable for placing the computer to "sleep" or pause for a given amount of time
' Reference information
timestart = now 'starts the stopwatch timer
folderInput = InputBox("How many folder do you wich to create: ", "folder amount", "any number between 1 and 6") 'the input box feilds
folderLocation = inputbox("Folder Location", "where would you like the folders to be placed", "C:\Documents and Settings\eriwal6880\Desktop\")
if folderinput <> "" then
folderamount = folderinput
else
quit
end if
' Worker and output information
Set LocalDrive = CreateObject("Scripting.FileSystemObject")
foldercheck
createfolder
folderamount = folderinput
wscript.echo("all done")
' *** Subroutines and functions are below ***
sub FolderCheck
If LocalDrive.FolderExists("folderlocation" & createfolder) Then
WScript.Echo("folder exists and will not be created")
Else
WScript.Echo("folder does not exist and will be created")
End if
end sub
function createfolder()
do until foldercount > folderamount
foldercount = 1
set createfolder = localdrive.createfolder(folderlocation & "folder" & foldercount)
wscript.echo createfolder
foldercount = foldercount +1
loop
end function
i got the inputbox's to work correctly but when i try to create the folders using a function it will only create one folder and gives me a runtime error stating that the folder already exists i know where the problem is but do not know how to fix it.
any and all help is greatly appreciated.
Thanks in advance
Eric
here are the requirements for my project:
Create a script that includes the following:
- Header section
- reference section
- Worker Information
- Output Information
- Document every line of the script
- All variable names must be unique
- determines how long the script will run
- Ask the user how many folders he wants to create by using a Msg Box
- check to see if folders exists
- ask the user where he wants to store the folders by using a Msg Box. Give the user an example of how to enter the information.
- create the folders by using Sub or a Function
- Create a file in each folder that you create. Add the following lines to the file:
- I am writing a script
- blank line
- For a grade in my IST321 course
- 2 blank lines
- I expect a good grade!
- Notify the user that you have created the file in the folder.
- use a counter and echo out each folder as it is created
- Use an Array.
- let the user know when the script is complete
' Header information
'
'========================================================
'
' File Name: IST321_EWalker_MidTerm.vbs
' This is a VBS script to run change the extention to .vbs
'
' Author: Eric Walker
' Date: July 7, 2011
'
'========================================================
option explicit
'on error resume next
dim TimeStart 'variable for time script started
dim TimeEnd 'variable for time script ends
dim TimeRan 'variable for total time script ran
dim FolderName 'variable for foldername
dim LocalDrive 'variable for c:
'dim CreateFolder 'variable
dim foldercount 'variable for folder counting
dim FolderInput 'variable for the number of folders the user wishes to create
dim folderamount 'variable for folderinput
dim filearray 'variable for array to store information about the files created
dim FolderLocation 'variable for the location of where the folders will be created.
dim textdocument 'variable for the text document that will be created in each new folder
dim sleep 'variable for placing the computer to "sleep" or pause for a given amount of time
' Reference information
timestart = now 'starts the stopwatch timer
folderInput = InputBox("How many folder do you wich to create: ", "folder amount", "any number between 1 and 6") 'the input box feilds
folderLocation = inputbox("Folder Location", "where would you like the folders to be placed", "C:\Documents and Settings\eriwal6880\Desktop\")
if folderinput <> "" then
folderamount = folderinput
else
quit
end if
' Worker and output information
Set LocalDrive = CreateObject("Scripting.FileSystemObject")
foldercheck
createfolder
folderamount = folderinput
wscript.echo("all done")
' *** Subroutines and functions are below ***
sub FolderCheck
If LocalDrive.FolderExists("folderlocation" & createfolder) Then
WScript.Echo("folder exists and will not be created")
Else
WScript.Echo("folder does not exist and will be created")
End if
end sub
function createfolder()
do until foldercount > folderamount
foldercount = 1
set createfolder = localdrive.createfolder(folderlocation & "folder" & foldercount)
wscript.echo createfolder
foldercount = foldercount +1
loop
end function
i got the inputbox's to work correctly but when i try to create the folders using a function it will only create one folder and gives me a runtime error stating that the folder already exists i know where the problem is but do not know how to fix it.
any and all help is greatly appreciated.
Thanks in advance
Eric
Last edited: