0

I want to delete some files from a remote computer's mapped(U:) drive within a WPF application.

I tried to use WMI like

"SELECT * FROM CIM_DataFile WHERE Drive='U:' and Path='\\Windows\\'"

But I found out that with WMI I can't access mapped drives of remote computer. Then I tried with psexec to start a cmd and give it as a parameter to delete it like

 p.StartInfo.Arguments = String.Format(@"-u Domain\User -p password -i \\{0}  cmd.exe /c rd U:\Windows /s /q", Hostname);

but it still didn't work. Is there any way to remove files from a remote computer's mapped network drive?

adam014
  • 25
  • 1
  • 5
  • I don't know why you're doing that with WMI in the first place... what's wrong with the [`File.Delete` Method](http://msdn.microsoft.com/en-us/library/system.io.file.delete(v=vs.110).aspx)? – Sheridan Aug 04 '14 at 10:23
  • I have to do it in a remote computer's mapped drive, which I couldn't reach with file.delete – adam014 Aug 04 '14 at 10:27
  • Your problem is *not* with `File.Delete`... it is with mapping the path to a UNC path: See if the accepted answer to the [How to get a fully qualified UNC path?](http://stackoverflow.com/questions/19404433/how-to-get-a-fully-qualified-unc-path) question helps you. – Sheridan Aug 04 '14 at 10:31
  • I just tried with the following query on a remote machine: "select * from Win32_MappedLogicalDisk" but it couldn't find anything. – adam014 Aug 04 '14 at 10:49

1 Answers1

0

Executing stuff in remote machines is cumbersome. The best solution I've found until now is using cygwin sshd (pretty overkill because the installation is big) but you won't have too much trouble with permissions.

I've tried powershell and psexec and both have problems with permissions.

Eric Lemes
  • 561
  • 3
  • 10