Jump to content

Logon script Windows server 2003


Recommended Posts

Good day ,

I am trying to make a login script that has to be executed when a user logs on the domain controller aka logon script.

I already made this.. but I don't know if I am doing it the good way,I have been searching allot on the forum.. but I cannot find the right answers

I also need a msg during logon every Friday to only 1 group in the AD ....

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.0.0
 Author:         Me

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
$answer = MsgBox(4, "Melding", "Als u inlogt op dit systeem gaat u er mee accoord dat als u misbruik maakt van het bedrijfsnetwerk dat u zal ontslagen worden op staande voet.")


If $answer = 6 Then

Msgbox(0, "Acceptatie", "Danku voor het accepteren van de gebruikersovereen komst! ")

Exit

EndIf 

If $answer = 7 Then

Run("shutdown.exe -l")


Exit

EndIf

NET USE P: \\deodora\$homedir /persistent:yes

NET USE X: \\deodora\$installdir /persistent:yes

NET USE S: \\deodora\$Afdelingsmappen /persistent:yes

NET USE F: \\deodora\$finafd /persistent:yes 

NET USE W: \\deodora\$directie /persistent:yes

plz I need help.. greetings strikey

p.s this is a AWESOME tool ^_^

some really nice apz on the forum

Edited by strikey
Link to comment
Share on other sites

  • Developers

Scary MsgBox() ... ^_^

You can use the AD UDF available in the Examples forum to check if the user that is login in is part of a AD group.

http://www.autoitscript.com/forum/index.php?showtopic=37378

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

IMHO - Kixtart would be a better choice for logon script as you can use the INGROUP function. It can also detect nested groups (Groups that are members of other Groups).

Autoit can do it but you will need to create a lot of your own code that Kixtart can do in 2 lines. You could call a Kixtart script to enumerate the groups and have it pipe the results back to Autoit if you really wanted to use Autoit and didn't want the learning curve of ADFunctions.au3

Link to comment
Share on other sites

IMHO - Kixtart would be a better choice for logon script as you can use the INGROUP function. It can also detect nested groups (Groups that are members of other Groups).

Autoit can do it but you will need to create a lot of your own code that Kixtart can do in 2 lines. You could call a Kixtart script to enumerate the groups and have it pipe the results back to Autoit if you really wanted to use Autoit and didn't want the learning curve of ADFunctions.au3

Hi,

if you have only XP clients in your network, maybe a choice:

1) Put your AD group in a seperate OU in your AD (e.g. MyOU)

2) Create and compile your MSGBOXES in Autoit for every User

; Script Start - Add your code below here
$answer = MsgBox(4, "Melding", "Als u inlogt op dit systeem gaat u er mee accoord dat als u misbruik maakt van het bedrijfsnetwerk dat u zal ontslagen worden op staande voet.")


If $answer = 6 Then

Msgbox(0, "Acceptatie", "Danku voor het accepteren van de gebruikersovereen komst! ")

Exit

EndIf 

If $answer = 7 Then

Run("shutdown.exe -l")


Exit

EndIfoÝ÷ Ûp«y«^jw¢jb쨺³(§ëh×è®Þ1«¢êT±êâ|Zâu¬ºÚ"µÍYÑ^HH
[ÙÐÞ
B[Y

4) Your login script should look like this:

autoit compiled 4 every User.exe

dsquery user -samid "%username%" |find "CN" | find "MyOU" > nul && goto MyOU

goto end

:MyOU

autoit compiled only for one AD Group.exe

:end

NET USE P: \\deodora\$homedir /persistent:yes

NET USE X: \\deodora\$installdir /persistent:yes

NET USE S: \\deodora\$Afdelingsmappen /persistent:yes

NET USE F: \\deodora\$finafd /persistent:yes

NET USE W: \\deodora\$directie /persistent:yes

;-))

Stefan

Edited by 99ojo
Link to comment
Share on other sites

  • 3 weeks later...

if @WDay = 6 Then

MsgBox (...........)

EndIf

this aint working :S

I put this in.. but it doenst compile to an exe :)

if @WDay = 5 Then

MsgBox ("MELDING" , "Let op! morgen zullen de week rapportages ingeleverd moeten worden")

EndIf

it says unable to parse line :party:

Edited by strikey
Link to comment
Share on other sites

  • Developers

Have your installed the Full Scite4AutoIt3 installer which runs au3check everytime to run or compile a script?

ERROR: MsgBox() [built-in] called with wrong number of args.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thnx I got that working..

but I needed to expand it.. tried everything.. this is the code I came up with.. but it errors (did the tidy thjing)

If @WDAY = 5 Then
    MsgBox("MELDING", "Let op! morgen zullen de week rapportages ingeleverd moeten worden")
EndIf
If @WDAY = 6 Then
    NET USE W: \\deodora\$directie
EndIf

So on Thursdays they will get an announcement ,and on the next day the appropriate networked drive will open up

Edited by strikey
Link to comment
Share on other sites

You can look at the DriveMapAdd() function to map your drives.

DriveMapAdd("W:" , "\\deodora\$directie" , 1)  ;(1 = /persistent:yes)

But at a minimum your going to have to change those commands to something like

ShellExecuteWait("NET USE W: \\deodora\$directie")
OR
RunWait(@comspec & " /c NET USE W: \\deodora\$directie")

AutoIT doesn't know what NET USE is so that's why your getting the errors.

For the UDF Jos posted, you would just need one short command like like this

If _ADIsMemberOf("USA Group", @username) Then
      Msgbox(0,"Group Check", "User is a meber of the USA Group")
;whatever commands you want to run.
EndIf

Kenny

Edited by ken82m

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

Thank you very much for the fast reply.. got the other scripts working tho .. but the *day* script is giving me an error on Thursdays

AUTO IT ERROR line-1: error incorrect number of parameters in function call

If @WDAY = 5 Then
    MsgBox("MELDING", "Let op! morgen zullen de week rapportages ingeleverd moeten worden")
EndIf
If @WDAY = 5 Then
    RunWait(@ComSpec & " /c NET USE W: \\deodora\$directie")
EndIf

and for this :

CODE
If _ADIsMemberOf("USA Group", @username) Then
      Msgbox(0,"Group Check", "User is a meber of the USA Group")
;whatever commands you want to run.
EndIf

I used some gpo's and bat files to do the net use commands and the start up thing :)

never mind got it running;)

it needed an 0 in front of message box

Edited by strikey
Link to comment
Share on other sites

For this one your just missing the first parameter,

Instead of this:
    MsgBox("MELDING", "Let op! morgen zullen de week rapportages ingeleverd moeten worden")

Try this:
    MsgBox(0, "MELDING", "Let op! morgen zullen de week rapportages ingeleverd moeten worden")

For the second one, what's the error exactly, does scite tell you what line or command it is?

I used some gpo's and bat files to do the net use commands and the start up thing

Cool, love gpo filtering :) Edited by ken82m

 "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Link to comment
Share on other sites

Already got it all working (the message) and the drive mapping .. well I am going to test that now...

Yes we all love the all powerful no-nonsense GPO's :)

dammit, Drive mapping aint working atm.. dont know why yet.. gonna post some updates later:P

Edited by strikey
Link to comment
Share on other sites

If @WDAY = 6 Then
    DriveMapAdd("W:", "\\deodora\Weekrapportages")
    RunWait(@ComSpec & " /c NET USE W: \\deodora\Weekrapportages")
EndIf

Is there a way that autoit is not closing the .CMD file? so that I can see momentarily what he is executing and if that is going all right

Link to comment
Share on other sites

  • Developers

If @WDAY = 6 Then
    DriveMapAdd("W:", "\\deodora\Weekrapportages")
    RunWait(@ComSpec & " /c NET USE W: \\deodora\Weekrapportages")
EndIf

Is there a way that autoit is not closing the .CMD file? so that I can see momentarily what he is executing and if that is going all right

replace /c with /k

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...