Page 1 of 1 1
Topic Options
#56517 - 2001-06-14 04:32 AM Msgbox to end script
dbortunk Offline
Fresh Scripter

Registered: 2001-05-18
Posts: 36
Loc: USA
Ok, I think this one is easy. I would like to write a little script in the beginning of the login script that will see if a user is a domain admin. If he is then it will prompt him whether the login script should be processed or not. If he clicks yes the login script will process if no then it will exit. Any suggestions? I was thinking msgbox but i am not sure how to do this.
Top
#56518 - 2001-06-14 05:54 AM Re: Msgbox to end script
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

Welcome to the board.

We have create a little script.
The first part can be used for code for all users.
The second part will only be executed for all NONE ADMINISTRATORS users
and for an ADMINISTRATORS user that press YES or that doesn't response
to the question after 1 minute.

code:

;
; - first part of your script f.e. to mapped minimum amount of drives
;
$execute_mode="yes"
IF (INGROUP("Administrators") <> 0)
$answer=MessageBox("Administrator, do you want to run the script?","Administrator",20,60)
IF ($answer = 7) ; - 7 = No -
$execute_mode="no"
ELSE ; - 6 = Yes / -1 = No response from user -
$execute_mode="yes"
ENDIF
ENDIF
IF ($execute_mode <> "yes")
GOTO end_script
ENDIF
;
; - second part of your script f.e. registry settings
;
:end_script
EXIT


Greetings.

------------------
Site map:

_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#56519 - 2001-06-15 04:28 AM Re: Msgbox to end script
dbortunk Offline
Fresh Scripter

Registered: 2001-05-18
Posts: 36
Loc: USA
Ok thanks that worked but now i want it also to look if you are loggin into an NT server as well (NT 4.0 and 2000 servers). I've tried different things but they don't work. It just logs in without running the script. I know this is easy but i can't figure it out.

$rtn=ReadValue("hkey_local_machine\system\currentcontrolset\control\productoptions","producttype")
$execute_mode="yes"
IF (INGROUP("Domain Admins") <> 0 AND ($rtn="SERVERNT"))
$answer=MessageBox("Administrator, do you want to run the login script?","Message",20,60)
IF ($answer = 7) ; - 7 = No -
$execute_mode="no"
ELSE ; - 6 = Yes / -1 = No response from user -
$execute_mode="yes"
ENDIF
ENDIF
IF ($execute_mode <> "yes")
GOTO end_script
ENDIF

Top
#56520 - 2001-06-16 01:41 AM Re: Msgbox to end script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Does not run the script?
at all?
or just runs it without question?

And simple question: why would you want to run user logon script on servers?!?!?
even thou they might not do any harm to the machine/system, it's not wise to do with server anything that ain't planned for: serving.
and even, I might suggest that you take of every logon script from the D_Admins and then use less powerfull user to do thinks that do need the logonscript.
well... discussion can keep on going, but...
suppose:
IF (INGROUP("Domain Admins") <> 0 AND $rtn="SERVERNT")
wont work.
what says then only either one?
try to make the script speak to you when it runs. nothing nice in the beginning. I use "I am here" and "in the if jubby"...


coding is boring if you don't want to search the error when the syntax is correct. 'cause it can take up lots of time.

_________________________
!

download KiXnet

Top
#56521 - 2001-06-16 03:54 AM Re: Msgbox to end script
MCA Offline
KiX Supporter
*****

Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
Dear,

We change the code a little and we are introducing the variable $server.
The message box will show which server was found.
Also we look at Windows 2000 and NT4 Domain_Controller. You see there are other values possible.
The code was stripped from our script os.kix.
New code:

code:

;
; - first part of your script f.e. to mapped minimum amount of drives
;
$execute_mode="yes"
$os_product=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions","ProductType")
SELECT
CASE (@inwin = 1) AND ($os_product <> "WinNT") AND (@dos = "5.0") ; - Windows 2000 -
$server="W2K_Server"
CASE (@inwin = 1) AND ($os_product = "LANMANNT") ; - Windows NT -
$server="NT4_Domain_Controller"
CASE (@inwin = 1) AND ($os_product = "ServerNT") ; - Windows NT -
$server="NT4_Member_Server"
CASE 1
$server="no"
ENDSELECT
IF (INGROUP("Domain Admins") <> 0) AND ($server <> "no")
$answer=MessageBox("Administrator, do you want to run the login script?","Message "+$server,20,60)
IF ($answer = 7) ; - 7 = No -
$execute_mode="no"
ELSE ; - 6 = Yes / -1 = No response from user -
$execute_mode="yes"
ENDIF
ENDIF
IF ($execute_mode <> "yes")
GOTO end_script
ENDIF
;
; - second part of your script f.e. registry settings
;
:end_script
EXIT

Some ideas:


  • we have no problem at all to run our script on any server at all. It detects automatically
    who is logged on and save all kind of information about this user.
    Also it is normally not possible that a normal user can reach the server.
  • we run those scripts on server to check all kind of things. Most important result is: everything
    works ok and some important information has been replicated between some servers.
  • by running scripts it is important what resources they are using. Very heavy scripts can
    stopped the primay task of servers for an unexpectable periode.
    The idea of asking to stop an unwanted script run we like.
    You may extend it with a time interval f.e. within office-hours this message box will be
    showed and in all other cases the script will be running.
  • another interesting thing of runnning script is: you may benchmark your server and you
    have the capability to see that the situation on your server is changing. We log those
    benchmark information to the eventlog.

Greetings.
_________________________
email scripting@wanadoo.nl homepage scripting@wanadoo.nl | Links | Summary of Site Site KiXforms FAQ kixtart.org library collection mirror MCA | FAQ & UDF help file UDF kixtart.org library collection mirror MCA | mirror USA | mirror europe UDF scriptlogic library collection UDFs | mirror MCA

Top
#56522 - 2001-06-18 02:11 PM Re: Msgbox to end script
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok.
that's even good that you have "some" scripts there to use.
I quess, i was little hard on you dbortunk.
keep going...

btw, mca you are right. as long as you keep your own scripts correct, you can use them on servers. with extra caution maybe...

_________________________
!

download KiXnet

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.06 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