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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting a File

Status
Not open for further replies.

Ravenrx7

IS-IT--Management
Aug 21, 2002
109
US
Hello,

I dont know if i'm evening posting this in the correct section, but its a very basic script issue im having, im just clueless on this scripts. I'm using visual basic, and I've attached the code below, i took over the admin position here, so i got to try to figure out why this code is not deleting the (3) listed files at the bottom of the code fand copying them from the server ( waps-dc2) to the user's windows folder, they're was alot more to this code but i reduced it since this is where the issue is
'*********************************************************
' Declare Vars
'*********************************************************
DIM wshNet
DIM strUser
DIM datadir
dim windir
DIM drivetally
Set DriveNet = WScript.CreateObject("WScript.Network")
Set CheckDrive = DriveNet.EnumNetworkDrives()
Set wshNet = WScript.CreateObject("WScript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")
Set wshShell = WScript.CreateObject("WScript.Shell")
DriveLetter = "P:"
strUser = wshNet.UserName
startDir = "C:\Documents and Settings\" & strUser & "\Start Menu\Programs\"
deskDir = "C:\Documents and Settings\" & strUser & "\Desktop\"
winDir= "C:\Documents and Settings\" & strUser & "\WINDOWS\"
dataDir = "\\WAPS-dc1\" & strUser &"$"



'*********************************************************
' STARREADING - 11/07/06, 01/23/07
'*********************************************************
if fso.FileExists(winDir) then
if fso.FileExists(winDir & "ALSBIGC.DAT") Then
set DelShort = fso.GetFile(winDir & "ALSBIGC.DAT")
DelShort.Delete
end if
if fso.FileExists(winDir & "ALSBIGC.FPT") Then
set DelShort = fso.GetFile(winDir & "ALSBIGC.FPT")
DelShort.Delete
end if
if fso.FileExists(winDir & "ALSPREFS.INI") Then
set DelShort = fso.GetFile(winDir & "ALSPREFS.INI")
DelShort.Delete
end if
fso.CopyFile "\\waps-dc2\starfiles$\ALSBIGC.DAT", winDir
fso.CopyFile "\\waps-dc2\starfiles$\ALSBIGC.FPT", winDir
fso.CopyFile "\\waps-dc2\starfiles$\ALSPREFS.INI", winDir
End if

'*********************************************************
' End of Script

Josh McMahon
A+ Certified,CCNA
sold@joshmcmahon.com
 
Actually, you're using VBScript rather than VB, and there's a separate forum for that. Personally, I don't use GetFile/Delete, I use DeleteFile. But, the reason that you can't delete the file is because some resource somewhere is using it. Probably because of something in the code you didn't post.

You may want to repost this in the vbscript forum: forum329.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top