Saving to root directory of windows 7

조회 수: 1 (최근 30일)
Johan
Johan 2011년 5월 21일
Hi there.
I have a matlab function that saves using fprintf...and it works just fine saving anywere, exept I can't save in the root, that is 'c:\' which is exactly where it needs to be saved. I can ofcourse save it somewhere else and then copy it to the root and say 'yes' or whatever when windows as me for persmission and admin rights and so on...
but I NEED to code it so that matlab saves it to "c:\filename".
which brings me to my question, is there anyway to get matlab to tell windows to ask for the admin rights when trying to save the file? that is via coding...
  댓글 수: 2
Daniel Shub
Daniel Shub 2011년 5월 21일
As a Linux user, I am not sure I can be much help. First, are you sure you need to save it to the root directory? Second, can you run MATLAB as root for this case?
Johan
Johan 2011년 5월 22일
well yes I have to save it to the root in this case, it's what the "task" is all about...sadly

댓글을 달려면 로그인하십시오.

채택된 답변

Johan
Johan 2011년 5월 26일
Solved it using !dir & mkdir c:\logdata which created a new folder on the root, and then after that used fprintf to ad file to the folder.
It isn't what I wanted to do, but still it's good enough to solve the problem
  댓글 수: 3
Johan
Johan 2011년 5월 26일
Yeah, I know it's not the best place, but when the user asks for it specifically, I don't want to argue, I wouldn't place it there either.
Jason Ross
Jason Ross 2011년 5월 26일
Yes, I have traveled the same road ... on some level you might consider it "job security" since you know they'll be back in the future :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 5월 21일
Perhaps you could system() a runas command that copies the file to where it needs to go. I seem to recall that runas prompts for the password.
  댓글 수: 2
Johan
Johan 2011년 5월 22일
Okay have been looking at the matlab help for system() and can't seem to find anything on doing runas or any similar, how would one do what you describe, syntax wise? or where can I get more info on the subject.
Walter Roberson
Walter Roberson 2011년 5월 22일
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/runas.mspx?mfr=true
It would simply be a Windows command-line that you submitted via system()
system(sprintf('runas /user:Administrator@YourComputerName move %s %s', oldfilename, newfilename))

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by