Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scripts not working. What am I missing 1

Status
Not open for further replies.

ftoddt

Technical User
Apr 26, 2003
180
US
Ok,
I am very new at this and trying to learn about this in the Windows 2000 Scripting Guide about vbScript, wsh, wmi, etc. I downloaded Windows Script 5.6 and installed it. I copied this script and changed the folder I wish to delete for practice as Scripts in the C: drive.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFolders = objWMIService.ExecQuery _
("SELECT * FROM Win32_Directory WHERE Name = 'c:\\Scripts'")
For Each objFolder in colFolders
errResults = objFolder.Delete
Wscript.Echo errResults
Next

or this script:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder("C:\Scripts")
pause


But all I get is nothing but an error such as this:
'objFSO.DeleteFolder' is not recognized as an i
operable program or batch file.

I feel like there is a dll or library file or program that is not installed in my win2k machine.
So what am I missing. All help is appreciated. Thanks
 
sorry, i forgot to destory the objects i used.
you should do this as best practice when you want to reuse the vairable name or you have done with the object completely

so right at the very end you would do

Set FSO = Nothing
Set WshShell = Nothing
Set objNetwork = Nothing
 
mrmovie,
Followup as Promised,
Well, I tried the scripts and they did not work for a couple of reasons. The mapped drives did not work and I kept getting an error that said it could not find the domain I was talking about so I have something wrong there in how I descripe the mapping .
The deleting files worked for me but not the students. I am thinking that the group policy for the students prohibts deleting anything off the computer so maybe that is what is stopping me even at login. Got some rethinking to do but will keep at it.
Here is the script I used and Thanks again,
Todd
Set objNetwork = WScript.CreateObject("Wscript.Network")
objNetwork.MapNetworkDrive "s:", "/home", True
objNetwork.RemoveNetworkDrive "R:"
objNetwork.RemoveNetworkDrive "v:"
objNetwork.MapNetworkDrive "r:", "\\wsd-fs1\reading", Tru

Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name = 'c:\\Program Files\\Msn Messenger'")

For Each objFolder in colFolders
errResults = objFolder.Delete


Next

Set colFolders = objWMIService.ExecQuery _
("Select * from Win32_Directory where Name = 'c:\\Program Files\\Messenger'")

For Each objFolder in colFolders
errResults = objFolder.Delete

Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top