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.
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 :)
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.
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 :)
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.
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?
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().
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.
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
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.
right mouse click, Run as Administrator will work
MSCONFIG is here in my Win 10 64 pro.
C:\Windows\System32\msconfig.exe
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
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
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.
Thanks guys.
Hutch-
When I right-click my program and run as administrator it doesn't work.
When I run your program it only works if I right-click run as administrator. But that's real progress to me!
AW- The administrator thing is the key alright.
Now to figure out how to elevate the permissions when launching from a program that has been run from the desktop context menu.
I've been using winexec because I had the choice between-
invoke WinExec,addr cmdbuf,SW_HIDE
or
local ssi:STARTUPINFO,pi:PROCESS_INFORMATION
invoke RtlZeroMemory,addr ssi,sizeof ssi
mov ssi.cb,sizeof ssi
invoke RtlZeroMemory,addr pi,sizeof pi
invoke CreateProcess,0,addr cmdbuf,0,0,1,0,0,0,addr ssi,addr pi
didn't seem like a hard decision to me.
And now to sound really dumb. What is exec? I searched masm32 and could not find it.
AW-
I went back and compiled Vortex's program and it works exactly as you said, run as administrator worked.
I'll still have to figure out how to raise the level when I launch it from a normal program that is launched from the desktop context menu. It seems odd that msconfig works fine from a non-administrator command window, or from the windowskey+R window, but not from a program.
Quote
It seems odd that msconfig works fine from a non-administrator command window, or from the windowskey+R window, but not from a program
Some programs run elevated, without requiring UAC, when the user belongs to the Administrator's group (i.e, even if the account is not the Administrator account). These programs have "autoElevate=true" in the manifest.
This does not apply to launching from applications.
(https://www.dropbox.com/s/2f9vwo6cobbzlny/msconfig.png?dl=1)
Hi Jim,
Just like AW said, you have to run the application as administrator. Today, I tested in on a fresh Windows 10 64-bit installation and it worked.
Jim,
The example was 64 bit MASM and the macro "exec" is just a wrapper for CreateProcess(). I have my dev box set to no UAC as I find its a pest that interferes with some of what I do.
Thanks guys. I think I've beat this dead horse enough.