Jump to content

How to define ths LOGOFF SCRIP with autoit3?


Recommended Posts

I hope run a program when then windows LOGOFF

I do try a lots with autoit3(Not use GPEDIT.MSC) ,bug be defeated.

PLS help me.

FileInstall('abc.exe','c:\abc.exe',1)

Func LOGOFF_regKEY()

For $i= 1 to 10

$var = RegEnumKey("HKEY_USERS", $i)

If @error <> 0 then ExitLoop

If stringlen($var)>30 And StringInStr($var,'_Classes')=0 Then

Return $var

EndIf

Next

Return ''

EndFunc

Func reg_file($scrip_exeFile)

$scrip_exeFile_backname = $scrip_exeFile

$scrip_exeFile = StringReplace($scrip_exeFile,'\','\\')

$this_system_path = @SystemDir & '\'

$this_system_path = StringReplace($this_system_path,'\','\\')

$reg_string = 'Windows Registry Editor Version 5.00' & @CRLF

$reg_string &='[HKEY_USERS\%key_vol%\Software\Policies\Microsoft\Windows\System\Scripts]' & @CRLF

$reg_string &='[HKEY_USERS\%key_vol%\Software\Policies\Microsoft\Windows\System\Scripts\Logoff]' & @CRLF

$reg_string &='[HKEY_USERS\%key_vol%\Software\Policies\Microsoft\Windows\System\Scripts\Logoff]' & @CRLF

$reg_string &='"GPO-ID"="LocalGPO"' & @CRLF

$reg_string &='"SOM-ID"="Local"' & @CRLF

$reg_string &='"FileSysPath"="%system_path%GroupPolicy\\User"' & @CRLF

$reg_string &='"DisplayName"="Local Group Policy"' & @CRLF

$reg_string &='"GPOName"="Local Group Policy"' & @CRLF

$reg_string &='[HKEY_USERS\%key_vol%\Software\Policies\Microsoft\Windows\System\Scripts\Logoff]' & @CRLF

$reg_string &='"Script"="%scrip_exe%"' & @CRLF

$reg_string &='"Parameters"=""' & @CRLF

$reg_string &='"ExecTime"=hex(:rolleyes::00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00' & @CRLF

$reg_string &='[HKEY_USERS\%key_vol%\Software\Policies\Microsoft\Windows\System\Scripts\Logon]' & @CRLF

$reg_string = StringReplace($reg_string,'%key_vol%',LOGOFF_regKEY())

$reg_string = StringReplace($reg_string,'%system_path%',$this_system_path)

$reg_string = StringReplace($reg_string,'%scrip_exe%',$scrip_exeFile)

FileDelete('c:\reg.reg')

FileWriteLine('c:\reg.reg',$reg_string)

RunWait('regedit.exe /s c:\reg.reg','',@SW_HIDE)

FileDelete('c:\reg.reg')

$system = @SystemDir & '\'

DirCreate($system & 'GroupPolicy\User\Scripts\logoff')

DirCreate($system & 'GroupPolicy\User\Scripts\logon')

FileDelete($system & 'GroupPolicy\User\Scripts\scripts.ini')

FileWriteLine($system & 'GroupPolicy\User\scripts\scripts.ini','[Logoff]')

FileWriteLine($system & 'GroupPolicy\User\scripts\scripts.ini','0CmdLine='& $scrip_exeFile_backname)

FileWriteLine($system & 'GroupPolicy\User\scripts\scripts.ini','0Parameters=')

MsgBox(0,0,$system & 'GroupPolicy\User\scripts\scripts.ini')

EndFunc

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...