Deleting files on remote servers

pts.
Tags:
VB.NET
VBScript
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • OpelikaTJ
    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 pointsBadges:
    report
  • Nuwarrior
    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 pointsBadges:
    report
  • Wizard90
    try: set oFs = CreateObject( "Scripting.FileSystemObject" ) oFs.DeleteFile( "servernamec$dirnamefilename.txt" ) set oFs = nothing
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following