first of all - if you removed "on error resume next", you would have seen this error immediately.
Next, I would recommend you try using the folder delete method on the remote PC instead of running cmd.
After that, you cannot run cmd.exe against C:\ and somehow make it run against a remote PC uless you launch the VBS with psexec or similar and target a remote PC.
I think this is closer to what you are after:
'First, we get the host name
strComputerName = InputBox ("Enter Hostname or IP to delete from")
'Next, we check the user actually entered a name or IP - you missed this!
if len(strComputerName) < 1 then
WScript.Echo "No Computer Name Entered - Quitting"
'next, we check it exists - you missed this bit too! no point in trying to remove folders from a non existant PC
If Reachable(strComputerName) Then
DeleteAFolder("\\" & strComputerName & "\c$\users\me\desktop\test")
DeleteAFolder("\\" & strComputerName & "\C$\folder\folder2")
WScript.Echo "Computer is Unreachable! - Quitting!"
'This function is the one called to check if the computer is reachable in line 11!
Dim wmiQuery, objWMIService, objPing, objStatus
wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strComputerName & "'"
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objPing = objWMIService.ExecQuery(wmiQuery)
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then
Reachable = False 'if computer is unreacable, return false
Reachable = True 'if computer is reachable, return true
'This function takes the name of the folders (lines 12 and 13) and deletes them
Set fso = CreateObject("Scripting.FileSystemObject")
'True in the line below includes read only folders
Just a quick note.. if this doesn't work - its probably a permissions thing, but I have no intention of expanding this script - so you're on your own from here.