Jump to content
Sign in to follow this  
strikey

Logon script Windows server 2003

Recommended Posts

strikey

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

Share this post


Link to post
Share on other sites
Jos

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


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
strikey

I already read that thread but I dont get it :S Is my script ok? and what does this mean? ( check if the user that is login in is part of a AD group. )...

Soz I am a bit of a noob:p

Share this post


Link to post
Share on other sites
Legacy99

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

Share this post


Link to post
Share on other sites
99ojo

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

Share this post


Link to post
Share on other sites
strikey

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

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
strikey

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

Share this post


Link to post
Share on other sites
ken82m

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

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
Share on other sites
strikey

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

Share this post


Link to post
Share on other sites
ken82m

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

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "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."

Share this post


Link to post
Share on other sites
strikey

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

Share this post


Link to post
Share on other sites
strikey

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

Share this post


Link to post
Share on other sites
Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
strikey

alright ill try to fix that somewhat later.. gonna try it tomorrow (Sundays ) lol :)

Share this post


Link to post
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
Sign in to follow this  

×