PDA

View Full Version : wsh: createing objects that already exist..



velious
02-19-2004, 05:30 PM
I dont understand this line of vbs code for wsh.

Set fso = CreateObject("Scripting.FileSystemObject")


the filesystemobject already exist, so why do you need to put the "createobject" thing there?

Roy Sinclair
02-19-2004, 06:09 PM
The CreateObject call creates an "instance" of the object, not the object itself.

velious
02-19-2004, 06:58 PM
could someone just give me one line of code to help me create a folder in wsh..
I know what the filesystemobject is one of the things i need, but i need some help on the rest of it, any help that anyone could give me is very welcome.

Roy Sinclair
02-19-2004, 07:37 PM
It takes three lines but:



Set fso = CreateObject("Scripting.FileSystemObject")
fso.CreateFolder ".\new folder"
Set fso = nothing

velious
02-19-2004, 08:43 PM
Thank you Roy, if you dont mind I got another question

I am making a script that asks the user if they want to connect to google.com.. if the user says "yes" then this string is susposed to connect them:

wscript.connect("http://www.google.com")

is that even possible in wsh or do i need some other program to do that?

Roy Sinclair
02-19-2004, 09:34 PM
Use the Run method of the Shell object:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsoriproperties.asp

Put the URL in place of the program name and then it'll start the user's default browser opening the indicated page.