Natulux Posted August 25, 2015 Author Posted August 25, 2015 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.GreetsNatulux
Surya Posted August 25, 2015 Posted August 25, 2015 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)
Natulux Posted August 25, 2015 Author Posted August 25, 2015 (edited) 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.RegardsNatuluxEDIT: 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 August 25, 2015 by Natulux
Surya Posted August 25, 2015 Posted August 25, 2015 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)
Natulux Posted August 25, 2015 Author Posted August 25, 2015 Yes, I will try that tomorrow.There must be a reason, why IniWrite() resisted my efforts though. I will tell you, if I succeed.Natulux
AdmiralAlkex Posted August 26, 2015 Posted August 26, 2015 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 RedirectorEither 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. Natulux 1 .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Natulux Posted August 26, 2015 Author Posted August 26, 2015 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\GroupPolicyis 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.inithough.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
AdmiralAlkex Posted August 26, 2015 Posted August 26, 2015 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. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
Natulux Posted August 26, 2015 Author Posted August 26, 2015 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\Scriptsand the scripts.ini now correctly displays[Startup] 0CmdLine=E:\FavMan_AktuellesRelease\ATOSS-FavoritenManager.exe 0Parameters=with either of Suryas samples.When using#AutoIt3Wrapper_UseX64=yas 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 sincerelyNatulux
Surya Posted August 27, 2015 Posted August 27, 2015 Glad that i could help 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)
Natulux Posted August 28, 2015 Author Posted August 28, 2015 (edited) At last here is the (slightly edited) code I used with success:expandcollapse popup#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 ;==>_RegisterGOPI 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 timeNatulux Edited August 28, 2015 by Natulux
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now