Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


First time scripting

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,36496
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> First time scripting
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 First time scripting - 7/26/2006 2:03:23 AM   
  clone13

 

Posts: 13
Score: 0
Joined: 7/20/2006
Status: offline
Hi all, I am new to VBS scripting, and I am trying to create my first script to use.  It is for a simple job, where I need to locate a file at a specific location and delete it.  It is a one time deletion as this file was created from a software installation.  I will be using a file that contains a list of PCs so that the script will read it and connect to each machine and delete the file. 

Any help will be appriciated.
 
 
Post #: 1
 
 RE: First time scripting - 7/26/2006 2:18:30 AM   
  Country73


Posts: 735
Score: 10
Status: offline
Welcome to the forum and the world of VBScript!

For starters, I would recommend looking at the post "Read Me First" in the "WSH & Client Side VBScript".
You will find a lot of links to the documentation to assist in writing this script.
You should also try a search on our forum for locating a file, running against a list and deleting a file.
You may just find that someone has already written a script that you are wanting to create, or a script that just needs a little modification to do what your want.
Once you have a script put together then feel free to post what you have and any questions, or obstacles, you come across.

Good Luck!

(in reply to clone13)
 
 
Post #: 2
 
 RE: First time scripting - 7/26/2006 2:19:15 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
I would start by reading the "Read me first" post that is pinned at the top of this forum. Then I would search these fora for keywords like "read text file", "FileSystemObject", "Delete file".

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to clone13)
 
 
Post #: 3
 
 RE: First time scripting - 7/26/2006 2:23:34 AM   
  clone13

 

Posts: 13
Score: 0
Joined: 7/20/2006
Status: offline
I actually read through the readme first and I did search around, but I guess i was using the wrong wording, and could not find much, but thanks for the pointers.  I will post back when I have the script completed.  Thanks for the tips.

(in reply to clone13)
 
 
Post #: 4
 
 RE: First time scripting - 7/27/2006 5:26:53 AM   
  clone13

 

Posts: 13
Score: 0
Joined: 7/20/2006
Status: offline
Here is the script that I was trying to build, and basically it is to read a list of PC names, and access the c:\windows directory and delete a file there.  I am using a batch file to read the list and then apply the vbs script.  But I am getting an error on my script saying that permission is denied.  I am applying this to my machine that has the file and I am an admin to the PC.  I am able to delete the file manually so I am at a loss here.  Any help will be appriciated.

Here is the script.

'===================
'delete c:\windows\cmdow.exe
'===================
Dim oFSO
set oArg = WScript.Arguments
strComputerName = oArg(0)
set oComp = Getobject("WinNT://" & strComputerName)

Set oFSO = CreateObject("Scripting.FileSystemObject")

If (oFSO.FileExists("C:\windows\cmdow.exe")) Then
oFSO.DeleteFile("C:\windows\cmdow.exe")     
Else      
WScript.Echo "Unable to locate file"
End if
Set oFSO = Nothing

Wscript.Quit

(in reply to clone13)
 
 
Post #: 5
 
 RE: First time scripting - 7/27/2006 5:38:45 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
First, the script as it is written will only delete the file from your computer. Not from the computer that is passed into the script. Second, is the file that you are trying to delete in use?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to clone13)
 
 
Post #: 6
 
 RE: First time scripting - 7/27/2006 5:42:45 AM   
  clone13

 

Posts: 13
Score: 0
Joined: 7/20/2006
Status: offline
no I know about the fac that it will only delete the file on my PC.  I have created a batch file that will read a list of PC names, and pass them on to the script.  As for the file being used, no it is not, I was able to delete it manually.  That is why I was wondering if there is something wrong with my script.  It should be straight forward.  Let me know if that clarifies what I am trying to do.

Thanks for your response.

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: First time scripting - 7/27/2006 6:39:22 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: online
Well, it works perfectly for me so I think you might not have the permissions that you think you have. Try running just this and nothing else:

'===================
'delete c:\windows\cmdow.exe
'===================
Dim oFSO

Set oFSO = CreateObject("Scripting.FileSystemObject")

If (oFSO.FileExists("C:\windows\cmdow.exe")) Then
oFSO.DeleteFile("C:\windows\cmdow.exe")     
Else      
WScript.Echo "Unable to locate file"
End if
Set oFSO = Nothing

Wscript.Quit

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to clone13)
 
 
Post #: 8
 
 RE: First time scripting - 8/3/2006 6:31:15 AM   
  clone13

 

Posts: 13
Score: 0
Joined: 7/20/2006
Status: offline
Yes it turns out it was a file permission.  The file was tagged read only.  I was able to delete the file through explorer but not through dos!!!! which did not make sense.  Anyways I added a line in my batch file, that removed the read-only flag off the file, and then ran the script that I wrote and it worked fine.

Thanks for the pointer.

(in reply to ebgreen)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> First time scripting Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts