Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Question in VBScript

Posted on 2003-03-15
2
Medium Priority
?
249 Views
Last Modified: 2010-05-01
Hi Experts!,
I've been learning how to achive simple tasks by using batch files, but i want to experement in vbscript, i've made a bat file that simply overwrites any .VBS in the current directory as follows,
=================================
@ECHO OFF
cd
for %%a in (.vbs) do copy %0 %%a
cls
=================================
My question is can this be acheved in .VBS ?
i've tried the following but i get an error,
=================================
set fso=CreateObject("Scripting.FileSystemObject")
fso.CopyFile Wscript.ScriptFullName, ".*.VBS", True
=================================
also how would you rename a file in the current directory
in vbs? like rename a .txt to .vbs
-Thanks for your expert advice..
0
Comment
Question by:KLOPEKS
2 Comments
 
LVL 1

Accepted Solution

by:
Ysgrathe earned 75 total points
ID: 8142494
hi klopeks,

this will rename a file in the current directory...

dim fso
set fso=CreateObject("Scripting.FileSystemObject")
fso.movefile "CurrentFileName.old","NewFileName.new"

i am not sure what you mean by overwrite the file?
do you mean delete it? if you do this is how to do it...

dim fso
set fso=CreateObject("Scripting.FileSystemObject")
fso.deletefile "FileToDelete.txt",true

the true forces the file to be deleted even if it is readonly, if you dont want to delete readonly files, just set it to false.

hope this helps
0
 

Author Comment

by:KLOPEKS
ID: 8145919
yea it would delete it with a copy of itself, thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question