LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do I shutdown my computer programmatically through LabView? lab

None
0 Kudos
Message 1 of 22
(9,900 Views)
Hi,

If you use Windows follow this link:
http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3EF4556A4E034080020E74861&p_node=DZ53008&p_submitted=&p_rank=&p_answer=&p_source=External

Download and unzip the package; in Winevent.LLB you find Exit Windows.vi

Good luck,

Alberto
0 Kudos
Message 2 of 22
(9,900 Views)
Hi,
you may use the WinAPI function from USER32.DLL

--------------------------------
Int32 ExitWindowsEx (int32 Flags, int32 Reserved)

The possible flags are:
EWX_LOGOFF = 0
EWX_SHUTDOWN = 1
EWX_REBOOT = 2
EWX_FORCE = 4
--------------------------------

You can use flags in any combination by adding to each other.
I've made the example for you it works fine on my PC.

Good luck.
Oleg Chukto.
0 Kudos
Message 3 of 22
(9,899 Views)
ExitWindows.vi and ExitWindowsEx will not work for a normal user under Win NT, 2000 and XP Professional since a normal user has not the right to shutdown windows.

You have to search in the internet for programs which do this. We use Winexit form http://posum.com which works fine.
Another way todo this is to write a program of your own. The sample source code is in the MSDN examples. You find this under security tokens.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 4 of 22
(9,899 Views)
Hi,
What does it mean that user has not rights to shutdown PC? If there are no more active users except me I have rights to shutdown it.
I've tested my vi under WinXP as ordinary user (not administrator) and it works fine. There were no more active users.
In any case I think that administrator can give the rights to shutdown PC to other users.

Good luck.

Oleg Chutko.
0 Kudos
Message 5 of 22
(9,899 Views)
Hi,
we are using Win NT 4.0 SP6a english and german versions. If you don't change any group settings all users of the group Users are not allowed to shutdown Windows. All the accounts in the domain where I work and on my home machine are in this group (execpt of the domain and local administrator and those you need for back office and other system tasks).

What normally happens when you shutdown is that explorer.exe (your standard shell) will call functions in a process named smss.exe. This process is responsible for login, logout and shut down. This process is the first process in the win32 subsystem of Win NT and Win 2000. Since no user is logged on when the process is created this one runs with system account. This is described in th
e book "Inside Microsoft Windows 2000".

For some reasons an account can change the security token which prevents the functions ExitWindows and ExitWindowsEx to do their expected work.

I have downloaded and tested Shutdown.vi on Win NT. I checked "Shutdown" and "Force" and let it run. Really my NT didn't shutdown. And you will get no error!

You say you are using WinXP. Since I have no WinXP available I could not test it. Maybe Microsoft has changed the default setting of the tokens so that ExitWindows and ExitWindowsEx work like on Win 98SE. Or do you have the home edition and not the professional? On XP Home there is only a limited security support like in Win98SE. So I think there it will work fine.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 6 of 22
(9,899 Views)
Hi,
A Rafiq has posted a VI and DLL which works on my machine. It seems that he forces always the choosen action, because I can see the dialog a short time on which you must confirm to abort running VIs.

You can find this in Programmatically shutdown of W2K.

There is no source code for the DLL in the zip, but A Rafiq is a enthusiast I think you can trust what he has done.

It is a good idea that NI will insert such a function in the application control palette. I think in the non-windows world it will be also useful.
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
0 Kudos
Message 7 of 22
(9,899 Views)
Hi,

Actually, the user might have the rights to shutdown the PC, the program
doesn't. A logout is allowed, because this does not require services to
stop.

A program can get the rights to shutdown the PC. It's not easy (lot's of
complicated VI's), but it can be done from LV. If you drop me a mail, I'll
send you the VI.

Regards,

Wiebe.



"waldemar.hersacher" wrote in message
news:506500000005000000A7C70000-1042324653000@exchange.ni.com...
> ExitWindows.vi and ExitWindowsEx will not work for a normal user under
> Win NT, 2000 and XP Professional since a normal user has not the right
> to shutdown windows.
>
> You have to search in the internet for programs which do this. We use
> Winexit form http://posum.com which works fine.
> Another wa
y todo this is to write a program of your own. The sample
> source code is in the MSDN examples. You find this under security
> tokens.
0 Kudos
Message 8 of 22
(9,898 Views)
Just write a dll that uses the shutdown api (relatively easy) in c++ or, if
you'r using a win nt system, just call a command line feature (shutdown -s).
there are some tips according a command line call by using labview.

"Wiebe@AIR" wrote in message
news:3e34f70a$0$151$e4fe514c@dreader8.news.xs4all.nl...
> Hi,
>
> Actually, the user might have the rights to shutdown the PC, the program
> doesn't. A logout is allowed, because this does not require services to
> stop.
>
> A program can get the rights to shutdown the PC. It's not easy (lot's of
> complicated VI's), but it can be done from LV. If you drop me a mail, I'll
> send you the VI.
>
> Regards,
>
> Wiebe.
>
>
>
> "waldemar.hersacher" wrote in message
> news:506
500000005000000A7C70000-1042324653000@exchange.ni.com...
> > ExitWindows.vi and ExitWindowsEx will not work for a normal user under
> > Win NT, 2000 and XP Professional since a normal user has not the right
> > to shutdown windows.
> >
> > You have to search in the internet for programs which do this. We use
> > Winexit form http://posum.com which works fine.
> > Another way todo this is to write a program of your own. The sample
> > source code is in the MSDN examples. You find this under security
> > tokens.
>
>
>
0 Kudos
Message 9 of 22
(9,898 Views)
Well, I get:

'shutdown' is not recognized as an internal or external command, operable
program or batch file.....

So this is probably a feature that is not standard.

It's not that difficult to get the SeShutdownPrivilege with
AdjustTokenPrivileges...

Regards,

Wiebe.



"Sebastian Dau" wrote in message
news:3e3927ae$0$205$4d4ebb8e@read.news.de.uu.net...
> Just write a dll that uses the shutdown api (relatively easy) in c++ or,
if
> you'r using a win nt system, just call a command line feature
(shutdown -s).
> there are some tips according a command line call by using labview.
>
> "Wiebe@AIR" wrote in message
> news:3e34f70a$0$151$e4fe514c@dreader8.news.xs4all.nl...
> > Hi,
> >
> > Actually, the us
er might have the rights to shutdown the PC, the program
> > doesn't. A logout is allowed, because this does not require services to
> > stop.
> >
> > A program can get the rights to shutdown the PC. It's not easy (lot's of
> > complicated VI's), but it can be done from LV. If you drop me a mail,
I'll
> > send you the VI.
> >
> > Regards,
> >
> > Wiebe.
> >
> >
> >
> > "waldemar.hersacher" wrote in message
> > news:506500000005000000A7C70000-1042324653000@exchange.ni.com...
> > > ExitWindows.vi and ExitWindowsEx will not work for a normal user under
> > > Win NT, 2000 and XP Professional since a normal user has not the right
> > > to shutdown windows.
> > >
> > > You have to search in the internet for programs which do this. We use
> > > Winexit form http://posum.com which works fine.
> > > Another way todo this is to write a program of your own. The sample
> > > source code is in the MSDN examples. You find this under security
> > > tokens.
> >
> >
> >
>
>
0 Kudos
Message 10 of 22
(9,503 Views)