How do you do....it? Thread, Help with beginner script/batch file to rename Program File? in Technical; Hi folks - despite all the related topics and some time Googling, I'm still really at a loss writing a ...
-
23rd June 2011, 01:36 PM #1 Help with beginner script/batch file to rename Program File?
Hi folks - despite all the related topics and some time Googling, I'm still really at a loss writing a script (or maybe even a batch file?) to rename a folder on client machines.
I'd like to set a startup script through GP to rename a folder (eg C:\Program Files\sausages) if it finds on the client machine.
I tried (please don't laugh... too hard...) the following:
if exist "c:\Program Files\sausages.gone" goto :EOF
if exist "c:\Program Files\sausages.com" rename "c:\Program Files\sausages.com" sausages.gone
@echo Job Run
Literally no idea what I'm doing. And do I go with vbs script or batch file for this you think?
Any help greatly appreciated.
And no there's no sausages on the network.
-
-
IDG Tech News
-
23rd June 2011, 01:46 PM #2 Also, I should probably add that if the folder "sausages.com" returns, I'd like it to be renamed.
-
-
23rd June 2011, 01:51 PM #3 VBS is probably easier from a debugging POV, although really it's personal preference.
This should do the trick (obviously replace the paths, unless you really do have sausages on your network...):
Code:
Option Explicit
Const sFolder = "C:\Sausages" 'Source folder
Const dFolder = "C:\walls" 'Destination folder
Dim FSO 'File System Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists(sFolder) Then FSO.MoveFolder sFolder, dFolder
Set FSO = Nothing Should all be self explanatory, but just in case, 'sFolder' is the folder you're checking the existence of, 'dFolder' is what the folder will be renamed to if it does indeed exist
EDIT: for re-usability, this script could be quite easily adapted to take command line arguments for source and destination folders, let me know if you'd like to see that script
-
Thanks to LosOjos from:
El_Nombre (23rd June 2011)
-
23rd June 2011, 02:05 PM #4 Thanks LosOjos! That'll keep the sausages at bay (wait what?)
-
SHARE:
Similar Threads
-
By Admiral208 in forum Scripts
Replies: 12
Last Post: 7th January 2011, 07:16 AM
-
By davidm in forum Windows
Replies: 3
Last Post: 26th March 2009, 10:37 PM
-
By Jackd in forum How do you do....it?
Replies: 2
Last Post: 19th November 2008, 08:39 AM
-
By MrLudwig in forum Windows
Replies: 13
Last Post: 8th December 2007, 03:40 AM
-
By tosca925 in forum Scripts
Replies: 4
Last Post: 23rd March 2006, 07:27 AM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules