Userinit replacement for Win7...
This script is src for autohotkey.
You "need the compiled exe" for this to work as a replacement for userinit.exe.
The ahk script that this code is, won't work in the src form at that stage of bootup.
You can copy the exe anywhere, but to use it you should change this:
Code:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"Userinit"="C:\\Windows\\system32\\userinit.exe,"
Update 3, 01/29/11:
Added notrayincon and fixed loading of uxsms.
I used winwait on the uxsms loading part to ensure it was done correctly on every boot on diff systems.
I may have to do the same for some of the reg key's later, programs like network indicator monitor don't work right unless explorer has been loaded up 100% before it loads up.
This program does not stay resident, and bootup speed has been increased from ver2.
Update 4, 02/02/11:
Fixed up loading file types for the programs\startup folder.
Now it only loads up: com, exe, bat, vbs, js and ahk files.
(Before it would load anything other then the desktop.ini file)
I still have to do the same for the other startup sections.
And add some sort of delay for loading these sections, it's still to fast and screws up "some" programs at startup (my network monitor in the post below and "network indicator monitor")
Update 5x..., 04/23/11
Been a while, I updated this along time ago, I figured I'de post the new code.
Can't remember what I changed though, probably some win2k3 fixes and such.
Code:
#NoTrayIcon
#SingleInstance, Force
#MaxMem 1
#MaxThreads 3
if A_OSVersion = WIN_7
{
Loop, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\RunServicesOnce, 0, 0
{
if A_LoopRegType = REG_SZ
{
RegRead, OutputVar
Run "%OutputVar%",, UseErrorLevel
if ErrorLevel = ERROR
{
}
}
}
Loop, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices, 0, 0
{
if A_LoopRegType = REG_SZ
{
RegRead, OutputVar
Run "%OutputVar%",, UseErrorLevel
if ErrorLevel = ERROR
{
}
}
}
Run "%windir%\explorer.exe"
;Sleep, 1000
;Fix for bypassing Stock Userinit...
RunWait %ComSpec% /C "net stop UxSms",, Hide
Run %ComSpec% /C "net start UxSms",, Hide
Loop, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce, 0, 0
{
if A_LoopRegType = REG_SZ
{
RegRead, OutputVar
Run "%OutputVar%",, UseErrorLevel
if ErrorLevel = ERROR
{
}
}
}
Loop, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\Run, 0, 0
{
if A_LoopRegType = REG_SZ
{
RegRead, OutputVar
Run "%OutputVar%",, UseErrorLevel
if ErrorLevel = ERROR
{
}
}
}
Loop, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Run, 0, 0
{
if A_LoopRegType = REG_SZ
{
RegRead, OutputVar
Run "%OutputVar%",, UseErrorLevel
if ErrorLevel = ERROR
{
}
}
}
FileList =
Loop, %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\*.*
{
FileList = %FileList%%A_LoopFileName%`n
Sort, FileList, R
Loop, parse, FileList, `n
{
if (A_LoopFileExt = "EXE" || A_LoopFileExt = "COM" || A_LoopFileExt = "BAT" || A_LoopFileExt = "VBS" || A_LoopFileExt = "JS" || A_LoopFileExt = "AHK")
{
; MsgBox "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\%A_LoopField%"
Run "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\%A_LoopField%"
}
break
}
}
Loop, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\RunOnce, 0, 0
{
if A_LoopRegType = REG_SZ
{
RegRead, OutputVar
Run "%OutputVar%",, UseErrorLevel
if ErrorLevel = ERROR
{
}
}
}
RunWait %ComSpec% /C "SetSystemFileCacheSize.exe flush", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
RunWait %ComSpec% /C "SetSystemFileCacheSize.exe off 16", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
RunWait %ComSpec% /C "SetSystemFileCacheSize.exe flush", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
}
else if A_OSVersion = WIN_2003
{
;win2k3 doesn't need extra code to parse startup stuffs, except for the extra file ext's...
Run "%windir%\explorer.exe"
;Sleep, 1000
;odd issue..., the loop file ext thingy is not working for some unknown reason...
;so for now, screw it, run all ext's
FileList =
Loop, %USERPROFILE%\Start Menu\Programs\Startup\*.*
{
FileList = %FileList%%A_LoopFileName%`n
Sort, FileList, R
Loop, parse, FileList, `n
{
; if (A_LoopFileExt = "EXE" || A_LoopFileExt = "COM" || A_LoopFileExt = "BAT" || A_LoopFileExt = "VBS" || A_LoopFileExt = "JS" || A_LoopFileExt = "AHK")
if (A_LoopFileExt = "AHK")
{
; MsgBox "%USERPROFILE%\Start Menu\Programs\Startup\%A_LoopField%"
Run "%USERPROFILE%\Start Menu\Programs\Startup\%A_LoopField%"
}
break
}
}
;Issue with win2k3, access denide error if I run the code below before this...
RunWait %ComSpec% /C "SetSystemFileCacheSize.exe flush", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
RunWait %ComSpec% /C "SetSystemFileCacheSize.exe off 16", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
RunWait %ComSpec% /C "SetSystemFileCacheSize.exe flush", %APPDATA%\Microsoft\Internet Explorer\Profile\Scripts\, Hide
;; installing deamontools doesn't work I dn which caused it
RunWait %ComSpec% /C "pskill smss.exe",, UseErrorLevel
if ErrorLevel = ERROR
{
}
;; Now is my chance to kill RpcSs
;; Find the PID for RpcSs and kill it
;; note this screws up paste, no longer works, greyed out
;; if I can redo the menu entry and remove this current one..., then maybe I can ungrey it
;tlst-mod|FINDSTR "^5.. svchost.exe$" > %TEMP%\PID-TEMP.txt
;SET /P PID_Temp=<%TEMP%\PID-TEMP.txt
;pskill %PID_Temp%
;; Print screen still works and so does paste in paint
;; the only thing that doesn't work is paste with files
;; because copy/paste in text files with text works fine
;; note also that delete files doesn't work ^^
;; but the cmd ver of del does work...
;; possible to replace, but...
;; I need to change the whatever it is that sets the generic cmds file each file type...
;; that might be alot of files, I dn how many it affects
;; but i think it might affect all ^^
;; then again, the right click context menu ver has allways been crappy compared to the cmd line ver anyways with certain files.
;; if I replaced it it would fix 2 things at once :)
;; how to do I use a var from multible batches and have it still work :\ ?
;; I guess the only way is with a temp file like the temp pid thing is right now unfortunately
;; so...
;; copy =
;; ECHO %1 > %TEMP%\Temp.txt
;; paste =
;; copy < %TEMP%\Temp.txt %D
;;copy = get var1 in batch
;;paste = copy var1 in current folder like cmd from here or something
;; Causes you to need to use Ctrl_Alt_Del to Restart (Shutdown and logoff cmd line cmd's works but restart doesn't)
;; Bitspirit also complains that it's not able to auto shutdown
;; this also seems to remove my rights for shutting down certain key system services from the taskmgr and such
RunWait %ComSpec% /C "pskill lsass.exe",, UseErrorLevel
if ErrorLevel = ERROR
{
}
Sleep, 1000
;prevent shutdown from the above work...
Run %ComSpec% /C "shutdown.exe /a",, UseErrorLevel
if ErrorLevel = ERROR
{
}
}