0 pts.
 Deleting files on remote servers
Good day, I currently have a web farm and and trying to use a vb script to delete file from remote servers. I have tried the following scripts. Shell ("del server1C$dir*.* /F /S /Q") This gives the error message, ensure files exist. then I tried this newProc = Diagnostics.Process.Start("c:windowssystem32cmd.exe", "del server1C$dir*.* /F /S /Q") this code opens the DOS box but doesn't execute the del command. Any help would be appreciated. Thanks

Software/Hardware used:
ASKED: June 19, 2007  4:40 PM
UPDATED: June 20, 2007  9:48 AM

Answer Wiki:
Be sure your paths are correct. (You appear to be missing some backslashes). Try typing the command at the command prompt (e.g. del server1sharefilename.ext /F /S /Q) to make sure the command and paths are correct. Then put the same command in your Shell() statement.
Last Wiki Answer Submitted:  June 19, 2007  6:43 pm  by  MrSamm   0 pts.
All Answer Wiki Contributors:  MrSamm   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

MrSamm,

Thanks for pointing that out, although in the actual code it does have the correct number of backslashes. This appears to be an issue directly related to VB trying to delete files using a UNC connection. If I call a batch file it works normally, but I am trying to avoid having to use a batch file so I can deploy this to other sites as well.

 0 pts.

 

I recently had a similar task of copying files between servers and although I wanted to use a UNC connection, I was discouraged by the network admin so I ended up using FTP instead.
The reason I was discouraged from using UNC was that each execution of the script had to establish the UNC connection and then close it when finished and this wouldn’t work if I had multiple VB scripts going at the same time. The only other alternative was to map the network drive to each server which the network admin did not like either.
Using an FTP connection, I was able to check for and/or create missing directories and then put files as needed and I can run multiple scripts concurrently without a problem.

HTH,
Gil.

 0 pts.

 

try:

set oFs = CreateObject( “Scripting.FileSystemObject” )
oFs.DeleteFile( “servernamec$dirnamefilename.txt” )
set oFs = nothing

 0 pts.