News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

System Settings Stub files

Started by hutch--, February 15, 2020, 11:33:36 PM

Previous topic - Next topic

hutch--

This is a more useful version of small stub files to change system settings. I have included a list of control panel calls using rundll32 and another list of the MSC files in my own Windows 10.

They all have this form.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    invoke ShellExecute,0,"Open","devmgmt.msc",0,0,SW_SHOW

    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

There is some overlap between using CreateProcess() and ShellExecute() and you can simply pick the one that best suits what you want. I have added in each example, a 4k icon so that the examples can be put on a desktop, any directory or even on a USB stick, the idea being that you don't have to conduct a wild goose chase through Win 10 to find a setting. Some of the options like MSC files can be set up from a command line on the desktop but this method is simpler to set up and can be moves from one location to another.

jimg

Interesting Hutch.   I already had shortcut icons for all of those on my desktop.   But it just dawned on me, it would nice to have them all presented as choices from one program, and then make that program show on the context menu for the desktop.  It would save me a bunch of desktop icons.   Thanks for the inspiration :)

hutch--

That's easy Jim, just make a window with menus. That is how I first tested the simple one liners that are used in the stubs.

jimg

Hi Hutch-

So you inspired me enough to slap together a program.

This program just presents a stack of buttons you can push to run a program.

To set the programs to show on the buttons, see the ini file.
The ini includes all the programs Hutch gave us in his files mscfiles.txt and rundllcmds.txt
I put my most used stuff at the top and commented out most of the rest.  Just move them around and comment/uncomment as desired.

To give you an idea, the start of the ini looks like this:
[Position]
Position=44,0,1,-1,-1,-1,-1,610,146,1018,740

[Commands]
; Enter two lines each, prompt followed by command e.g.
;Prompt
;Command
; Sort as desired, comment out unwanted.
; note**** most of these came from Hutch's files mscfiles.txt and rundllcmds.txt ***

Programs and Features
rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,0

Device Manager
devmgmt.msc

Disk Cleanup Utility
cleanmgr

etc.

This was a quickie slap together bits and pieces program so don't squint too closely :)


I also included two reg files.  One to add the program to the desktop context menu, and one to remove the program from the registry.  This is what makes it really convenient to me, being able to right-click anywhere on the desktop to run one of these things, rather than having to move windows around to find a desktop icon or scrounge through folders.

Finally, thank again Hutch for getting me going.  This is something I wish I had years ago :)

hutch--

Works fine here Jim. One quirk as I use slightly different font sizes on my desktop, the last option I can see is being cut off by the bottom of the window.

jimg

Yup, not a lot of checking in the program.  It really should have been a scrolling listview, but when I started I didn't think there would be that many things that I wanted.  So, how many things are you trying to show?  I'm only using 20 myself :)  On my screen there would be room for about 45.  Also it's resizable and remembers the size you set, but I'm sure you already knew that.

I do have one question though.
I found I could do both types, the rundll and .msc type with the same command, WinExec "cmd /D/C rundll32.exe shell32.dll,Control_RunDLL hdwwiz.cpl" or WinExec "cmd /D/C devmgmt.msc", or pretty much any other executable.

But one has defied me.  I can run msconfig manually from a command window prompt, or a run window, but it just won't execute with WinExec.  Any ideas why?

hutch--

I stuck to either CreateProcess() or ShellExecute() which can run either MSC or rundll32 apps OK. WinExec is a backwards compatible wrapper for CreateProcess() and it may not run all of the rundll32 applets. If it does not, use ShellExecute().

jimg

ShellExecute returns ERROR_FILE_NOT_FOUND even when I give it the full path, which I suppose is better than winexec that returns success.  Doesn't work with LoadModule either.  There's just something odd about msconfig.

Vortex

Hi Jim,

Considering that your operating is 64-bit, if you are trying to build a 32-bit application launching msconfig, you need to take in account the file system redirection :

https://docs.microsoft.com/en-us/windows/win32/winprog64/file-system-redirector?redirectedfrom=MSDN

Tested on Windows 7 64-bit :

include     \masm32\include\masm32rt.inc

.data

cmdline     db 'C:\Windows\Sysnative\msconfig.exe',0

.code

start:

    invoke  WinExec,ADDR cmdline,SW_SHOW

    invoke  ExitProcess,0

END start

jimg

Doesn't work on Windows 10, at least not my windows 10.
Using sysnative, I get "the specified path does not exist".  Apparently wow64 is not recognizing sysnative as it should.  It doesn't work from the command prompt or the run box either.

It's odd that every other single thing I try to run works, msconfig is the ONLY one that doesn't work.  e.g. I can run cleanmgr from the same folder without a problem.

aw27

right mouse click, Run as Administrator will work

hutch--

MSCONFIG is here in my Win 10 64 pro.

C:\Windows\System32\msconfig.exe

jimg

Hutch- That's where my msconfig is also.  I just can't find any way to launch it from inside a program.

AW- If you mean right click on utilities.exe and run as administrator, I tried that with the same results.  Won't lauch msconfig from a program.  But you may be on to something.  If you are able to run it from a program, I may have something else screwed up in my permissions.  I always run from an administrator account so should be good, but when I open a command window from a program, perhaps the new window does not have those permissions.  I'm doing-

invoke WinExec,"cmd /D/C msconfig",SW_HIDE

hutch--

Jim,

Just run it with the plain command line.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

entry_point proc

    exec "C:\Windows\System32\msconfig.exe"

    .exit

entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end

aw27

I meant, launch the Vortex's program either from an Administrator command prompt, or by mouse right-click + Run As Adminstrator or with a manifest with requireAdministrator.
So, it does not work if the account is not elevated, even if it belongs to the Administrators group.