Sign in to follow this  
Followers 0
BrandonPerry

Another msconfig script

6 posts in this topic

#1 ·  Posted (edited)

Hi, I am learning AutoIt and am wanting to write an msconfig script on my own to disable all startup application. I don't understand what I am doing wrong. I expect msconfig to come up and flash by doing the controlclicks I write, but it seems that it runs in the background and when I compile to an EXE, it just generates dozens of msconfig processes until I quit the script or reboot. I am probably doing something very stupid, and have looked at examples of code doing this same thing, but mine doesn't work as others do and I can't figure out why. Could anyone look over my code and tell me what I am doing wrong? I am running Windows 7 Ultimate x64.

Also, I am sad to see there is no active IRC channel (afaict anyways).

#Include <GUITab.au3>

$MSCONFIG = 'System Configuration'
Run('msconfig.exe')
WinWait($MSCONFIG)
Sleep(1000)
_GUICtrlTab_SetCurFocus(ControlGetHandle($MSCONFIG, '', '[CLASS:SysTabControl32;INSTANCE:1]'), 3)
ControlClick($MSCONFIG, "", "[CLASS:Button; INSTANCE:2]")
Sleep(500)

ControlClick($MSCONFIG, "", "[CLASS:Button; INSTANCE:22]")
Sleep(500)

ControlClick($MSCONFIG, "", "[CLASS:Button; INSTANCE:20]")
Sleep(500)

ControlClick($MSCONFIG, "", "[CLASS:Button; INSTANCE:3]")
Sleep(500)
Edited by BrandonPerry

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you aren't compiling your exe with the name msconfig are you?

Edited by kaotkbliss

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That fixed the looping, renaming the script to clean_msconfig.au3. Thanks.

However, the script is still not behaving as I expect. It isn't bringing msconfig up and cleaning the startup tab. Am I missing something else?

Edited by BrandonPerry

Share this post


Link to post
Share on other sites

This is what I do to remove startup items.

; Remove any startup items
    Dim $aRegKeys[18] ; create array of startup items to delete
    $aRegKeys[0] = "dwtrig20" ; watson subscriber
    $aRegKeys[1] = "Apoint" ; apls pointing driver
    $aRegKeys[2] = "snp2uvc" ; sonix sound
    $aRegKeys[3] = "Persistence"
    $aRegKeys[4] = "IgfxTray" ; intel graphics helper
    $aRegKeys[5] = "HotKeysCmds" ; intel extreme controlers
    $aRegKeys[6] = "AESTFltr" ; andrea audio driver
    $aRegKeys[7] = "sm56hlpr" ; modem helper
    $aRegKeys[8] = "smax4pnp" ; soundmax systray
    $aRegKeys[9] = "sttray" ; IDT sound tray
    $aRegKeys[10] = "RTHDCPL" ; realtek audio manager
    $aRegKeys[11] = "stsystra" ; sigmatel audio systray
    $aRegKeys[12] = "QlbCtrl" ; hp quicklaunch
    $aRegKeys[13] = "SynTPEnh" ; synaptics touchpad
    $aRegKeys[14] = "Quicktime Task" ; quicktime
    $aRegKeys[15] = "iTunesHelper" ; itunes helper
    $aRegKeys[16] = "hkcmd" ; intel graphics helper
    $aRegKeys[17] = "igfxpers" ; intel common user interface module

    ; Loop to delete startup registry keys
    For $g = 0 To UBound($aRegKeys) - 1
        RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$g])
        If @error <> 0 Then
            ; do nothing
        Else
            For $r = 0 To UBound($aRegKeys) - 1
                RegDelete("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", $aRegKeys[$r])
                Sleep(100)
            Next
        EndIf
    Next

Share this post


Link to post
Share on other sites

I figured it out. Windows 7 x64 performs odd file redirection for 32-bit applications. Prepending the following like to the script fixes this.

DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)

Share this post


Link to post
Share on other sites

My code ended up looking like this:

#RequireAdmin
#include <GuiTab.au3>
;
DllCall("kernel32.dll", "int", "Wow64DisableWow64FsRedirection", "int", 1)
ShellExecute("C:\Windows\System32\msconfig.exe", -2)

WinWait("System Configuration")

Sleep(500)
$hSysConfig = WinGetHandle("System Configuration")

$hTab = ControlGetHandle($hSysConfig, "", "SysTabControl321")

ControlCommand("System Configuration","","SysTabControl321","TabRight","")

;Click services
_GUICtrlTab_ClickTab($hTab, 2)
Sleep(50)

;Check the hide
ControlCommand($hSysConfig, "", "Button3", "Check")
Sleep(50)

;Disable all
ControlClick($hSysConfig, "", "Button2")
Sleep(50)

;Click startup
_GUICtrlTab_ClickTab($hTab, 3)
Sleep(50)

;Disable all
ControlClick($hSysConfig, "", "Button2")
Sleep(50)

; Apply
ControlClick($hSysConfig, "", "Button13")
Sleep(50)


ControlClick($hSysConfig, "", "Button11")
Sleep(50)

$hSysConfig = WinGetHandle("System Configuration")

ControlClick($hSysConfig, "", "Button3")
Sleep(50)

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  
Followers 0