Author Topic: System Settings Stub files  (Read 512 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7059
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
System Settings Stub files
« on: February 15, 2020, 11:33:36 PM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jimg

  • Member
  • ***
  • Posts: 444
Re: System Settings Stub files
« Reply #1 on: February 16, 2020, 01:00:51 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7059
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: System Settings Stub files
« Reply #2 on: February 16, 2020, 01:13:02 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jimg

  • Member
  • ***
  • Posts: 444
Re: System Settings Stub files
« Reply #3 on: February 17, 2020, 11:30:22 AM »
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:
Code: [Select]
[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--

  • Administrator
  • Member
  • ******
  • Posts: 7059
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: System Settings Stub files
« Reply #4 on: February 17, 2020, 11:54:03 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jimg

  • Member
  • ***
  • Posts: 444
Re: System Settings Stub files
« Reply #5 on: February 17, 2020, 12:52:31 PM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7059
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: System Settings Stub files
« Reply #6 on: February 17, 2020, 05:15:42 PM »
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().
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jimg

  • Member
  • ***
  • Posts: 444
Re: System Settings Stub files
« Reply #7 on: February 17, 2020, 05:49:29 PM »
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

  • Member
  • *****
  • Posts: 2109
Re: System Settings Stub files
« Reply #8 on: February 18, 2020, 06:34:26 AM »
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 :

Code: [Select]
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

  • Member
  • ***
  • Posts: 444
Re: System Settings Stub files
« Reply #9 on: February 18, 2020, 10:30:19 AM »
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.

AW

  • Member
  • *****
  • Posts: 2567
  • Let's Make ASM Great Again!
Re: System Settings Stub files
« Reply #10 on: February 18, 2020, 08:26:46 PM »
right mouse click, Run as Administrator will work

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7059
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: System Settings Stub files
« Reply #11 on: February 18, 2020, 09:32:03 PM »
MSCONFIG is here in my Win 10 64 pro.

C:\Windows\System32\msconfig.exe
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jimg

  • Member
  • ***
  • Posts: 444
Re: System Settings Stub files
« Reply #12 on: February 19, 2020, 01:20:29 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7059
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: System Settings Stub files
« Reply #13 on: February 19, 2020, 01:28:01 AM »
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
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

AW

  • Member
  • *****
  • Posts: 2567
  • Let's Make ASM Great Again!
Re: System Settings Stub files
« Reply #14 on: February 19, 2020, 01:30:48 AM »
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.