Jump to content

Recommended Posts

Posted

//JScript
var fso;
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.DeleteFolder("C:\\foldername");
 
'VBScript
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder("C:\\foldername")

 

Code from JScript5.chm and Vbscrip5.chm

 

Edit: Sorry guys, vbscript uses one slash and JScript uses two slashes. JScript uses two slashes as the first slash is used to denote an escaped character such as \n \r \t etc where as vbscript use vbCr vbLf vbTab and so on.

Posted
//JScript
var fso;
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.DeleteFolder("C:\\foldername");
 
'VBScript
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder("C:\\foldername")

 

Code from JScript5.chm and Vbscrip5.chm

 

Bit of a daft question but I have always seem some code snippets in delete or copy files or folders with one slash ie \ and others with 2 ie \\

 

such as this :

 

//JScript

var fso;

fso = new ActiveXObject("Scripting.FileSystemObject");

fso.DeleteFolder("C:\\foldername");

 

'VBScript

Dim fso

Set fso = CreateObject("Scripting.FileSystemObject")

fso.DeleteFolder("C:\\foldername") '<-- in the directory path there is \\

 

Just wanted to know what difference does it make ?

Posted

There's a freeware prog called orphan remover that scans the start menu for dead shortcuts and removes them. It can be ran in a quiet mode from a script.

 

Where I used to work for had student accounts set up not to process the all users profile instead all the shortcuts came from the students mandatory profile. We then had orphan remove set to kill the shortcuts for any progs that weren't installed on that particular machine.

Posted
Have a look on the microsoft scripting site. There a plenty of snippets on there you can play around with and put together to make your own scripts. If you look under the sticky in the scripting section you will also see a few programs that will create basic scripts for you.
Posted

Using this code

 

'VBScript

Dim fso

Set fso = CreateObject("Scripting.FileSystemObject")

fso.DeleteFolder("C:\\Documents and Settings\All Users\Start Menu\Programs\folder1")

fso.DeleteFolder("C:\\Documents and Settings\All Users\Start Menu\Programs\folder t2")

 

When the folder does not exist i get the following message, any ideas please?

Posted
stick
 On Error Resume Next

at the start of your script, that will ignore any errors thay occur when it runs.

 

Mike.

 

Thats the easy way but the correct way would be to check if the folder exists then try and delete it else do nothing.

Posted

I suspect that the problem is with the double back slash in the VBS.

I don't recall having to use it in leteral path references.

 

Now JScript with its nod to its Java/Unix roots uses // because a single forward slash in a quoted string normally introduces control characters.

Posted
stick
 On Error Resume Next

at the start of your script, that will ignore any errors thay occur when it runs.

 

Mike.

 

Thats the easy way but the correct way would be to check if the folder exists then try and delete it else do nothing.

 

You are indeed correct! (but I'm always one for the easy option.)

 

My VBS coding skills are limited!

 

Mike.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • 47 When would you like EduGeek EDIT 2025 to be held?

    1. 1. Select a time period you can attend


      • I can make it in June\July
      • I can make it in August\Sept
      • Other time period. Comment below
      • Either time

×
×
  • Create New...