Jump to content

Script takes ages on startup


Recommended Posts

Hey Surya,

no need to apologize, I'm happy that you are helping me! :-)

I tried your code but unfortunately nothing happened.
After changing
 

$fini = "C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini"

to
 

$fini = "C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts1.ini"

I got confused. It didn't even create the nonexistent scripts1.ini. I just updated AutoIt to the newest version 3.3.14.1, maybe there's a difference?
The help file claimed: "If the file does not already exist, it is created so long as the directory exists.", but it doesn't!

Not sure what I'm missing.

Greets
Natulux

Link to comment
Share on other sites

natulux just copy down the whole script and runn it in scite then open cmd and type what i said earlier. do not edit anything .The code works fine for me.Can you please do what i said and post me the results

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Link to comment
Share on other sites

Sure, here you go:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "D:\Programmierung\MyProjects\AutoIt\ATOSS_FavMan\FavManStartup.au3" /UserParams    
+>17:21:58 Starting AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0   Keyboard:00000407  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64    Environment(Language:0407)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\MKramer\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\MKramer\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.1)  from:C:\Program Files (x86)\AutoIt3  input:D:\Programmierung\MyProjects\AutoIt\ATOSS_FavMan\FavManStartup.au3
+>17:21:58 AU3Check ended.rc:0
>Running:(3.3.14.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "D:\Programmierung\MyProjects\AutoIt\ATOSS_FavMan\FavManStartup.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
+>17:22:00 AutoIt3.exe ended.rc:0
+>17:22:00 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 2.479

"FavManStartup.au3" is the .au3 file with your code without any changes. You can see the results of the debugger console above.
I can't see, why it wouldn't do something...

Script.ini is empty.

Regards
Natulux

EDIT: I added admin rights, to be sure. Didn't help:
 

#RequireAdmin
If IsAdmin() Then MsgBox($MB_SYSTEMMODAL, "", "The script is running with admin rights.")

 

Edited by Natulux
Link to comment
Share on other sites

then i would cut short the code simply to its bones here it is:

#requireadmin
$fini = "C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini"
IniWrite($fini,"Startup","0CmdLine","E:\FavMan_AktuellesRelease\ATOSS-FavoritenManager.exe")
IniWrite($fini,"Startup","0Parameters","")

This would write the script.ini after running this code check wether the script.ini is empty

No matter whatever the challenge maybe control on the outcome its on you its always have been.

MY UDF: Transpond UDF (Sent vriables to Programs) , Utter UDF (Speech Recognition)

Link to comment
Share on other sites

Well according do the console output you posted you are running x86 AutoIt on x64 Windows, that means you would be opening the file in WysWOW64 not System32.

File System Redirector

Either make sure you are using x64 with #AutoIt3Wrapper_UseX64=y or work around it with \Sysnative folder. You probably shouldn't mess around with Wow64DisableWow64FsRedirection() if you don't know what you're doing.

Link to comment
Share on other sites

Hello AdmiralAlkex,

I'm not sure if I understand that. I mean, how does x86 AutoIt influence, where the ini file should be edited, when I give a full path?
 

$fini = "C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini"
IniWrite($fini,"Startup","0CmdLine","E:\FavMan_AktuellesRelease\ATOSS-FavoritenManager.exe")

Nevertheless,
 

C:\Windows\SysWOW64\GroupPolicy

is empty and that would explain, why IniWrite() doesn't like to create a file.

When I am adding my script to the Group Policy by hand, my OS adds an entry to the
 

C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini

though.

Surya, even the plain code you gave me doesn't work. The ini file stays empty. I sense that IniWrite() has some kind of problem...

Kind regards,
Natulux
 

Link to comment
Share on other sites

Hello AdmiralAlkex,

I'm not sure if I understand that. I mean, how does x86 AutoIt influence, where the ini file should be edited, when I give a full path?

Because x86 apps are redirected to the x86 System folder and vice versa. See the link in my previous post.

Link to comment
Share on other sites

Hello again AdmiralAlkex,

I'm very sorry and you are right. I should have checked that link first.
My command really is redirected to
 

C:\Windows\SysWOW64\GroupPolicy\Machine\Scripts

and the scripts.ini now correctly displays

[Startup]
0CmdLine=E:\FavMan_AktuellesRelease\ATOSS-FavoritenManager.exe
0Parameters=

with either of Suryas samples.

When using

#AutoIt3Wrapper_UseX64=y

as suggested, I really am able to write to system32 though.

I guess I'm happy now! :-)
Thank you both, I've learned quite a lot here.

Yours sincerely
Natulux

Link to comment
Share on other sites

At last here is the (slightly edited) code I used with success:

#RequireAdmin
#AutoIt3Wrapper_UseX64=y

#include <Array.au3>
#include <String.au3>

Local Const $GOP_SHUTDOWN = False
Local Const $GOP_STARTUP = True
;the first parameter defines to start the script when in startup or shutdown
;second parameter is the file and third is its parameters
;------------


_RegisterGOP($GOP_STARTUP,"E:\FavMan_AktuellesRelease\ATOSS-FavoritenManager.exe")
RegWrite("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "ATOSS-FavoritenManager", "REG_SZ", @ScriptFullPath)

Func _RegisterGOP($varx, $file, $param = "")
    Local $nLast, $nNum, $fIni
    Local $strScriptname = "ATOSS-FavoritenManager.exe"
    $fIni = "C:\Windows\System32\GroupPolicy\Machine\Scripts\scripts.ini"
    If FileExists($fIni) Then
        If $varx = $GOP_STARTUP Then
            $ini = IniReadSection($fIni, "Startup")
            If @error Then
                Local $ini[1][1]
                $ini[0][0] = -1
            EndIf
        ElseIf $varx = $GOP_SHUTDOWN Then
            $ini = IniReadSection($fIni, "Shutdown")
            If @error Then
                Local $ini[1][1]
                $ini[0][0] = -1
            EndIf
        EndIf
        For $i = 1 To UBound($ini) - 1
            If StringInStr($ini[$i][2],$strScriptname) Then
                $nNum = $i
            EndIf
        Next

        If Not $nNum Then
            $nLast = UBound($ini) - 1
            $nNum = _StringBetween($ini[$nLast][0], "", "P")
            If @error Then Local $nNum[1] = [-1]
            $nNum = $nNum[0] + 1
        EndIf

        If $varx = $GOP_STARTUP Then
            IniWrite($fIni, "Startup", $nNum & "CmdLine", $file)
            IniWrite($fIni, "Startup", $nNum & "Parameters", $param)
        ElseIf $varx = $GOP_SHUTDOWN Then
            IniWrite($fIni, "Shutdown", $nNum & "CmdLine", $file)
            IniWrite($fIni, "Shutdown", $nNum & "Parameters", $param)
        EndIf
    Else
        If $varx = $GOP_STARTUP Then
            IniWrite($fIni, "Startup", "0CmdLine", $file)
            IniWrite($fIni, "Startup", "0Parameters", $param)
        ElseIf $varx = $GOP_SHUTDOWN Then
            IniWrite($fIni, "Shutdown", "0CmdLine", $file)
            IniWrite($fIni, "Shutdown", "0Parameters", $param)
        EndIf
    EndIf
    Return "Success"
EndFunc   ;==>_RegisterGOP

I added a Regestry startup entry with a link to my script and a routine to check, if my script has already been added to the ini file.

Have a great time
Natulux

Edited by Natulux
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

×
×
  • Create New...