Page 1 of 2 12>
Topic Options
#56544 - 2001-06-14 11:27 AM remote logoff nt4.0
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Hi All,

I was wondering if anybody knows of a good way to enforce a user logoff on a remote machine using kix and/or extra tools.

I'm currently working on a script that is kind of a "command module" for our helpdesk. it connects to a machine's c$ and when it has, it present you all sorts of options what to do with pc (take over with VNC, RCMD, net send etc. etc.)
One of the options is the removal of certain applications.

The probem is that certain applications have one or more files that stay "locked".

I figured by forcing a logoff in a "xnet shutdown" kind of way ensures me the files aren't locked anymore and also the user will receive the logonscript (wich installs the apps again).

I have been looking around now for a while and have read mostly articles stating it cannot be done..

I can always fall back to tools that log off locally and call them using rcmd or anything but i would really like to do it without such a workaround.

is there a way ??

THANX,

MvdW

_________________________
rgrds, Maarten

Top
#56545 - 2001-06-14 01:00 PM Re: remote logoff nt4.0
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
Note : Even it's for 98/Me, the rundll32 command works under 95

from Ms KB : http://support.microsoft.com/support/kb/articles/Q234/2/16.ASP

You can use either of the following commands in a batch file to restart Windows 98/Me automatically:

runonce.exe -q
rundll32.exe shell32.dll,SHExitWindowsEx n

where n is one, or a combination of, the following numbers:
0 - LOGOFF
1 - SHUTDOWN
2 - REBOOT
4 - FORCE
8 - POWEROFF

The above options can be combined into one value to achieve different results. For example, to restart Windows forcefully, without querying any running programs, use the following command line:
rundll32.exe shell32.dll,SHExitWindowsEx 6
NOTE: Using the FORCE option can cause programs to lose data.

_________________________
? getobject(Kixtart.org.Signature)

Top
#56546 - 2001-06-14 01:16 PM Re: remote logoff nt4.0
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Thanks popovk fo rthe response,

forgot to mention in first post but we are working nt4.0 only environment. i hav etested this command under nt but it gives an error message:
"Error in Shell32.dll Missing entry SHExitWindowsEx"

but also if it had worked, i would still have to somehow issue the command to run on the remote machine.

What i am actually looking for is a command that is run on my machine and logs off a user on a remote machine.

i would imagine some tool like :
remotelogoff.exe \\remoteip /switch


Any ideas ??

_________________________
rgrds, Maarten

Top
#56547 - 2001-06-14 02:27 PM Re: remote logoff nt4.0
Alex.H Offline
Seasoned Scripter

Registered: 2001-04-10
Posts: 406
Loc: France
In fact, NT was said (in the title), but i was blind

Ok, after playing a little with shell32, the command is exitwindowsex, but i wasn't able to call it (and any other command from shell32)

I think the syntax is not the same, or it can be a missing right. Dunno

Seems you'll need a 3rd party utility.

_________________________
? getobject(Kixtart.org.Signature)

Top
#56548 - 2001-06-14 03:03 PM Re: remote logoff nt4.0
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Well the reskit does contain logoff.exe but again it will only work on the local machine the command is run on.

Anybody ??

_________________________
rgrds, Maarten

Top
#56549 - 2001-06-14 03:43 PM Re: remote logoff nt4.0
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh there is:
shutdown.exe!!!
it can't be stopped. It's also in reskit (in free tools version).
I might check also for logoff way, but if you want really unlock files only way is to kill every system service-> shutdown.

------------------
Lonkero

The weardest there is!

_________________________
!

download KiXnet

Top
#56550 - 2001-06-14 04:47 PM Re: remote logoff nt4.0
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
shutdown shuts down.

i want to log off. just like the shutdown program. but then just logoff.

i am sure that the best way to kill all files is to shutdown, but a logoff is sufficient in this case (trust me...)

is there a way or is there not, if anybody knows pls let me know.

Thanx

_________________________
rgrds, Maarten

Top
#56551 - 2001-06-14 06:06 PM Re: remote logoff nt4.0
bleonard Offline
Seasoned Scripter
*****

Registered: 2001-01-19
Posts: 581
Loc: Chicago, IL
mvdw -
Why not use VNC or Net Meeting to take complete control of the Desktop, then perform normal Windows logoff from there?
Also, if files are 'locked', likely due to process running, so you could also try remotely killing process(es).

Interested in seeing/learning the script you are working on - I take in one goal is manipulate system at command level without end-user knowledge? Also, are you really running RCMD service on every WinNT system?

Bill

Top
#56552 - 2001-06-14 06:31 PM Re: remote logoff nt4.0
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Hi bleonard,

Spot on, i could use gazillion of different ways for takeover logoff, but i am a believer in stealth administration.

The script is basically some exploded experiment. The environment i am working in has about 120+ domains all over the world, and most of the data lines are 32k 16k even 8k. besides that 10 helpdeskers and 8 level2 engineers along with 3 service managemnet people have to share a single BISDN line to the main network...

i don't know how many of you have ever tried to work across these types of lines but i can assure you your patience is tested to the MAX. So because there is no proper implementation of WINS nor DNS (don't ask me why, you know large company politics) we need a way of managing all these machines with the least possible amount of user interaction.

it all started out as a script from a colleague that checks for VNC installation, if so it cracks the password from the registry and starts a VNC session (all based on just ip input) otherwise it installs VNC and starts the session.

From there i took over and implemented RCMD in the script, then some basic information gathering, net send, removal of certain applications, map drive, reboot, even built in nameresolving using selfadministered list of servers etc etc.

Real multifunctional tool for helpdesk purposes giving us the opportunity to do a lot of "underwater" troubleshooting.

The last thing that is nagging me at the moment is the logoff. because sometimes it takes up to 15 mins just to send ctrl alt del and click logoff and ok when using VNC.
This wouldn't even have come up in my mind if the lines weren't so damn slow.

everywhere i look on the internet i see logoff .exe etc and posts that it cannot be done remotely but i am still not sure (ther SHOULD be a way shouldn't there ???!?!)

I will post the script as soon as i have the time to strip it from our site specific passwords etc...

Ciao,
MvdW

_________________________
rgrds, Maarten

Top
#56553 - 2001-06-15 02:23 AM Re: remote logoff nt4.0
bleonard Offline
Seasoned Scripter
*****

Registered: 2001-01-19
Posts: 581
Loc: Chicago, IL
mvdw -
The Win2K Resource Kit has a 'logoff.exe' utility. I have not tested. I am confident will not work in Win9x environment like most such reskit tools. Let me know if you've tested, or want me to email to you.

Bill

Top
#56554 - 2001-06-15 10:36 AM Re: remote logoff nt4.0
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
MVDM! there is ultimater answer to you.
create a kix process that does only hanging.
you know "do sleep 5 until 1=2"
and when you want to logoff kill the process.
it will logoff every user, even administrators.

------------------
Lonkero

The weardest there is!

_________________________
!

download KiXnet

Top
#56555 - 2001-06-15 11:50 AM Re: remote logoff nt4.0
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Hi MvdW,

I have not tried this, but, how about doing something like this...

Copy the LOGOFF.EXE file to all of the systems.
Create an AT schedule on all of these systems that runs say once every couple of hours. Then have it look for a zero byte size flag file. If not found have the AT service execute the LOGOFF.EXE file. In the Run or Startup group have the system create this zero byte flag file so that the system will not keep logging off accidentally. Then if or when you want to log off a system you can remotely delete this flag file.

Or possibly something like this:

at \\remotecomputer 13:00 cmd "/c logoff.exe"

I also found this resource on the WEB that might work or be helpful. He has a remote logoff utility in pre-beta. http://wwwthep.physik.uni-mainz.de/~frink/nt.html

Please post and let us know if any of these solutions/suggestions work out for you.

------------------
NTDOC...
The dark side is quicker, easier, more seductive.
If you choose the quick and easy path, you will become an agent of evil.

Top
#56556 - 2001-06-15 03:30 PM Re: remote logoff nt4.0
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Hi NTDOC,
--------------------from webpage mentioned above------------

This program consists of two parts: INITLO, a program which runs with SYSTEM privilege and initiates the logoff proces, and LOGOFF, which runs under the user's security context and does the actual logoff, because only the user himself can call the ExitWindowsEx() API with the EWX_LOGOFF parameter (at least I have not found any other way).
Copy INITLO.EXE and LOGOFF.EXE somewhere to the machine where you want to log off the user (you can do this over the network with NET USE \\machine\c$ as Administrator). The designated method to start INITLO is with the AT command (or more comfortably with the SOON command from the NT Resource Kit, because you do not have to specify an absolute time). You can use AT to start processes on other machines on your network. The Schedule service must run on the target machine. If it does not, you can start it remotely with NETSVC from the NT Resource Kit. Therefore you should always be able to use INITLO/LOGOFF even on unprepared workstations completely over the network.

INITLO must run under an account which has SE_DEBUG_NAME, SE_ASSIGNPRIMARYTOKEN_NAME, SE_CREATE_TOKEN_NAME and SE_SECURITY_NAME privileges. By default, only the SYSTEM account (not even the Administrator) has theses privilege. Take this into account if you have configured the Schedule service to run under a different user.

----------------------------------end------------
(The afore- and belowmentioned logoff.exe is not the one in the reskit but written by Alexander Frink see http://wwwthep.physik.uni-mainz.de/~frink/logoff/readme.html)

As i read it, the logoff .exe uses the ExitWindowsEx() API with the EWX_LOGOFF parameter and this can only be called by the logged on user. Initlo can be run from localsystem account and thus by using initlo to call logoff.exe ,logoff.exe is run under user privs.

the strange thing is that when i use AT to schedule it works fine. (he also mentions that scheduler service must run under system account which in my situation it does)

the strange thing is that RCMD service also runs under localsystem account but when i issue the command from an rcmd session it won't work.

Here comes the good (but a bit sad) part. i cannot use the scheduler service because this would create too much delays. Our environment spans ALL timezones and the experience we have is that scheduling in our environment is useless unless you schedule from the local machine... (imho it has to do with shortcomings in the scheduler service from NT)

This is the final solution ...???!!!

i use rcmd (whic is a pity because i have to first make sure in the script that it is installed otherwise install it (meaning a copy of rcmdsvc.exe and a xnet install and a xnet start then another check to see if it runs))
the rcmd command i issue is a soon (have to copy also... hmmpf)
I have to give soon a delay of 60 secs because otherwise it assumes it is the same minute and therefore schedules it the next day (thanx for the 2 sec local delay.. mr m$)
and with that soon i schedule initlo to run the logoff.exe and then it works... syntax:

rcmd \\ipaddress "soon 60 "initlo -g 2""

which works !!!

the problem (or in oter words... a bit strange) is that in this worst case i need to copy rcmdsvc.exe, soon.exe, initlo.exe and logoff.exe to the ws, check/start/check schedule service and install/check rcmd

JUST TO LOG OFF while i can just issue shutdown with a ready made tool.

It's a crazy world in my opinion

Thanx NTDOC for this website, but if there is ever going to be a tool like shutdown (which simply works) i'd much rather use that instead.

_________________________
rgrds, Maarten

Top
#56557 - 2001-06-15 06:06 PM Re: remote logoff nt4.0
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Well i have tested some more and this way even works when the user has locked his machine. (WoW !!)

I can live with the fact that there is some copying to do and some service checking but i do find it a real pity that the soon command needs a 60 sec delay in order for it to function properly (shame on you MS !)

Better luck in a next life ?!

Ciao,
MvdW

_________________________
rgrds, Maarten

Top
#56558 - 2001-06-16 12:20 AM Re: remote logoff nt4.0
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Hello MvdW


You owe me a BIG Cookie for this one.

I have tested this and it works GREAT!! on our systems. Does not need any installation. Copy to your own system and start the program. Enter the name of the Windows NT/2000 remote system and BANG!!! Restart/Shutdown the system.

Actually I guess you owe the author the cookie, but I want some crumbs for a finders fee.. :-)

Poweroff is a small program for Win95/98/NT/W2K to schedule a
shutdown/reboot/logoff/poweroff at a certain time. I also support
command line options that allows poweroff to be used in batch scripts.
It now also supports shutdown/reboot of a remote computer and the
possibility to warn the user.

http://users.pandora.be/jbosman/applications.html


NTDOC

[This message has been edited by NTDOC (edited 16 June 2001).]

Top
#56559 - 2001-06-16 01:20 AM Re: remote logoff nt4.0
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
It was a time...
it was possible, but really weird ever no one wanted to make such a program.
offcourse it needs coding and maybe some fooling of the system, but that is what remote admin tools do.

THANKS to ntdoc and jbosman.

_________________________
!

download KiXnet

Top
#56560 - 2001-06-18 08:09 AM Re: remote logoff nt4.0
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
Well NTDOC,

it was a nice try by the belgian guy, however also he only supports shutdown/reboot NOT logoff on a remote machine. I think the german guy was right it can't be done. Or at least it can only be done as described above.

regards,

MvdW

_________________________
rgrds, Maarten

Top
#56561 - 2001-06-18 09:26 AM Re: remote logoff nt4.0
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Hi MvdW

I'm sorry, your right. I liked the program so much I forgot you were looking for logoff, not remote restart. You can have your cookie back :-(


From the README
You can use poweroff to do a reboot/shutdown on a remote NT/2000 system
(logoff and poweroff are not supported by windows )

Oh well, sorry about that. Still a nice program for those of us who want these other features.

NTDOC

Top
#56562 - 2001-06-18 02:00 PM Re: remote logoff nt4.0
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
that's nice.
I was thinking about it. most easily it would be done with a script/program that runs as system service (servany.exe).
and call that service then from remote machine.
I haven't tried so don't know for sure.
_________________________
!

download KiXnet

Top
#56563 - 2001-06-18 08:17 PM Re: remote logoff nt4.0
mvdw Offline
Starting to like KiXtart

Registered: 2001-05-01
Posts: 124
Loc: Voorburg, Netherlands
NTDOC,

Thanks anyway, it IS a nice program... i am just an ass i guess always looking for that little bit extra you shouldn't be looking for... (story of my life..)

Lonkero, before you start losing your hairs over this one, read the website of the german guy from the University of Mainz, i think he is trying to say that the logoff API can only be called by an interactive user. This would mean that whatever stunt you pull it better be good (and it should at least be better then just issuing/scheduling some sort of logoff tool from a remote machine, especially if it is ran as a service under the system account)

Anyways, i think we have done enough polluting, the forum is about scripts, not about non-existent MS tools.

Thanx everybody for the help...
over and out

Ciao,
MvdW
(i'm just gonna have me a nice battle with backup exec and maybe after about 6 or 8 hrs of overtime i may finally call it a day...grrrrr)

_________________________
rgrds, Maarten

Top
Page 1 of 2 12>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 793 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.078 seconds in which 0.031 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org