system('shutdown /r')

I wish to restart my machine from MATLAB at 3am say and then call a bat file to run MATLAB from windows task scheduler.
When I put the code:
system('shutdown /r')
at the end of my MATLAB process it restarts the machine fine, but only takes it to the windows login page. Hence task scheduler will not work from this point - it needs to be logged in (caveat - task scheduler can still call processes, but those processes may not be able to run as they need to be logged in -e.g. if they have a GUI).
how can I fully restart my machine from matlab, specifying my password (and perhaps my username/ login)?
I am running win7, MATLAB 2010B, 64bit.
many thanks

6 件のコメント

Daniel Shub
Daniel Shub 2012 年 5 月 1 日
Do you really need to log in and have a full interactive MATLAB session, or could you run MATLAB with the -nodesktop flag and have it all hidden? What type of security do you need for your machine (i.e., is autologin a possibility? )
Matlab2010
Matlab2010 2012 年 5 月 1 日
I do need a full session, as I have a GUI.
The security is flexible, but I can not remove the requirement for a login password, though I could specify my password in a bat file/ matlab.
Daniel Shub
Daniel Shub 2012 年 5 月 1 日
This is not really a MATLAB question, but rather a question about Windows task scheduler. While you might get an answer here, you might be better off on a Windows type site.
Matlab2010
Matlab2010 2012 年 5 月 1 日
I think knowing how to restart your machine through MATLAB is a MATLAB question.
The use of task scheduler or not is nothing to do with restarting the machine through MATLAB.
thank you for your input though.
Kevin Holst
Kevin Holst 2012 年 5 月 1 日
You started out your question stating that system('shutdown /r') restarted your computer just fine. That's not really a MATLAB question more like a statement. The real question is how do you get past your login and restart MATLAB, so as Daniel said, you'll probably be better served through a Windows site.
Daniel Shub
Daniel Shub 2012 年 5 月 1 日
I am not trying to be negative, I was just trying to guide you someplace that might get you an answer faster.

サインインしてコメントする。

 採用された回答

Jan
Jan 2012 年 5 月 1 日

0 投票

In Windows 7 this allows to enable an auto login:
control userpasswords2
Start this either in command section of the start menu or per system() command from Matlab. Admin privilegs are required.
[EDITED] I cannot imagine a situation, where a shut-down and auto-login is really helpful. Everything, what can be performed during a shutdown + reboot can be done with an active machine also.
Perhaps a virtual machine could solve your problem. You can restart it from Matlab without the need to shut-down before. And the security problem is smaller.

4 件のコメント

Jason Ross
Jason Ross 2012 年 5 月 1 日
The ability to change this setting may depend on if a computer is in a domain, as well. I tried launching it on my Windows 7 machine and it could not find it, but I know I've used the checkbox described on people's home machines.
Matlab2010
Matlab2010 2012 年 5 月 2 日
Jason -- you are correct. you can not run this as a domain member. you have to leave the domain and run as a stand alone machine.
Jan -- For the same reasons you need to reboot a machine normally. memory fragmented, stuff running you don't know about, get back to "default settings" etc etc
Yes. this approach does give the security problem that anyone with physical access to the machine has full control!
Daniel Shub
Daniel Shub 2012 年 5 月 2 日
I think the security issue is bigger than that. I think the machine can be compromised remotely. I believe the password is being stored in plain text someplace, so the security issues are similar to storing the password in plain text in a bat file. Someone with limited remote access may be able to gain your password and then gain "full" control.
Walter Roberson
Walter Roberson 2012 年 5 月 2 日
When I was managing unix servers, it wasn't uncommon for them to be up for over a year. Memory fragmentation is not a problem in any modern operating system.

サインインしてコメントする。

その他の回答 (2 件)

Matlab2010
Matlab2010 2012 年 5 月 1 日

0 投票

This seems to be a commonly asked question.
It seems like the most likely command I need to pass to system.m is "net logon".
This allows you to pass your username domain name and password at the command line.
However, I can not get the syntax working in win7.

3 件のコメント

Jason Ross
Jason Ross 2012 年 5 月 1 日
You are barking up the wrong tree there. Net logon (and friends like "net use" or "net view") are used once you have an active command shell or script to gain access to a network resource by setting some credentials. They also have the huge security hole mentioned in my other reply -- if you use them in a scripted environment, the password of the account is in plain text on the command line.
Jason Ross
Jason Ross 2012 年 5 月 1 日
an example where you would use "net logon" would be if you needed to get to a network share but you were not a member of the domain. You could use "net logon" to set up the credentials you wanted to use, then use "net use" to map the drive.
An equivalent GUI method is using "map network drive" to map a network drive as someone other than the user you are logged in as.
Matlab2010
Matlab2010 2012 年 5 月 1 日
ok. this agrees with what I was reading on various forums re map network drive GUI. clearly not what I need then.

サインインしてコメントする。

Jason Ross
Jason Ross 2012 年 5 月 1 日

0 投票

NOTE: THIS IS A GIANT SECURITY HOLE SINCE YOUR PASSWORD WILL BE STORED IN PLAIN TEXT IN THE REGISTRY. USE AT YOUR OWN RISK AND THINK ABOUT WHAT YOU ARE DOING.
You can set your machine to login automatically using the three Registry keys described in the following article:
Did I mention this is a huge security hole?

3 件のコメント

Matlab2010
Matlab2010 2012 年 5 月 1 日
Having the password stored in plain txt is fine in my case.
I will have a play and report back.
thanks
Jan
Jan 2012 年 5 月 1 日
The linked article concerns Windows 2000. See my answer.
Jason Ross
Jason Ross 2012 年 5 月 1 日
It works for all versions of Windows I've ever used.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

タグ

質問済み:

2012 年 5 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by