c# - How to access rstrui.exe from code behind? -


please tell me how access system restore "rstrui.exe" c# code.

i tried calling c:\windows\system32\rstrui.exe; not accessible @ all.

i need call function redirecting controls system restore.

thanks....

you can access c:\windows\system32 using following property:

environment.systemdirectory 

environment.systemdirectory property

you can run executable using following method:

process.start(path.combine(environment.systemdirectory, "rstrui.exe")); 

path.combine method

process.start method

update >>>

ahhh... see problem.

when accessing system32 folder 32 bit code on 64bit windows 7 , vista (maybe windows 8 too), windows 'cleverly' changes part of request path syswow64. why may have got 'could not find path' error. in order around this, can use following:

process.start(@"c:\windows\sysnative\rstrui.exe"); 

a more complete answer might be:

if (environment.is64bitprocess) {     process.start(path.combine(environment.systemdirectory, "rstrui.exe")); } else process.start("c:\\windows\\sysnative\\rstrui.exe"); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -