VB.NET Chaining commands to cmd.exe -


i've been trying chain commands firstly self delete application delete directory in resided through process in vb.net application. here's @ far code concerned.

i found useful code sample self deleting applications:

dim fldpath string = "c:\test" dim inf processstartinfo = new processstartinfo() inf.arguments = "/c choice /c y /n /d y /t 3 & del " & """" application.executablepath & """" inf.windowstyle = processwindowstyle.hidden inf.createnowindow = true inf.verb = "runas" inf.useshellexecute = true inf.filename = "cmd.exe" process.start(inf) application.exit() 

the above code works treat , self deletes application. i'd, however, delete folder in resides. have tried chaining commands in arguments process application deletion happens , folder remains, e.g:

inf.arguments = "/c choice /c y /n /d y /t 3 & del " & """" application.executablepath & """" & "&rmdir /s /q " & """" & fldpath & """" 

concatenating rmdir command not yield results, recursively deleting directory (and not bothering application deletion) not seem work.

edit: further comments given far, have preiously tried recursively removing directory without success, aka argument as:

inf.arguments = "/c choice /c y /n /d y /t 3 & rmdir /s /q " & """" & fldpath & """" 

the above deletes file not remove folder. if show cmd prompt, error effect file still in se application.

inf.arguments = "/c choice /c y /n /d y /t 3 & del /s /q " & """" & application.executablepath & """" 

the above deletes file without issue. need chain command remove containing directory.

just further clarification. seems error "process cannot access file because being used process" relates directories! added empty directory , text file run command. files deleted failed on new folder /s switch off.

inf.workingdirectory = "c:\" 

changing working directory above (from default, assume, current one) did not yield results. noted above, process fails on directories , not chaining, insight appreciated.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -