How run a Winbatch program in "elevated" mode?

Started by pguild, November 18, 2022, 03:25:52 PM

Previous topic - Next topic

pguild

I think this means running as an admin.  When I run the wallpaper code from Winbatch studio it gives me a black screen. How would I run it with admin rights or in some elevated mode? 8)

Thanks.
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

ChuckC

Right-click the shortcut in the start menu or on task bar, or the actual program file [via File Explorer], and then click on "Run as Administrator".  Do this for WinBatch Studio, or for your compiled script.  Refer to the WinBatch documentation about how to set the correct "manifest" so that the compiled script will automatically prompt for elevation.


td

If you want to run an uncompiled script as an elevated admin, change the file extension from ".wbt" to ".wbt_at" or ".wbt_af". As Chuck mentioned set the manifest so that a compiled version of your script executes as an elevated process. For more information you can check out the following:

https://docs.winbatch.com/mergedProjects/WinBatch/Manifests.htm
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

pguild

I changed the file extension from .wbt to .wbt_at and I still get black wallpaper instead of the desired wallpaper image.
I also tried a .wbt_af extension will the same undesirable results: a black wallpaper.
screen.

I also complied .exe with "highest available" and did a right click on the .exe file.
Then I chose run as Admin and still the same result.  It just does not work for me, yet.

I yearn for a solution to this wallpaper background solution.  >:( :o :( ??? ::) :'(
Here is the code:
;changewallpaper.wbt_af
;changewallpaper.wbt_at
;changewallpaper.wbt
;If you want to run an uncompiled script as an elevated admin,
;change the file extension from ".wbt" to ".wbt_at" or ".wbt_af".

DirChange("f:\Creating Power Habits")
a = FileItemize("*.jpg")
a = AskItemlist("Select New paper", a, @TAB, @UNSORTED, @SINGLE, @FALSE)
TILE = @FALSE
If FileSize(a) < 40000
TILE = @TRUE
pause("TILE lesson thatn 40000",TILE)
else
pause(a,"file size 40000 or more")
endif
Wallpaper(a, TILE)
pause("Done","hahaha")
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer

td

The WallPaper function works in testing as long as you are executing it with elevated admin privileges. If it is not working for then I guess you are out of luck...

I suppose you could try to modify the registry settings for the desktop background directly using WIL registry functions. However, I have never heard of the registry approach working on Windows 11.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

I did get this to work on Windows 11 but it required that I log out and log back in after running the script.

Code (winbatch) Select

; You would need to change the file path and name to a location and file present on your system.
RegSetValue( @REGCURRENT, "Control Panel\Desktop[WallPaper]", "C:\Bitmaps\2008_10_27\167-6737_IMG.JPG")
RegSetValue( @REGCURRENT, "Control Panel\Desktop[WallpaperStyle]", "2")
exit
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

Should have noticed this earlier but you are not adding the full path to the selected image file name. The WallPaper function communicates the new image file to the Windows shell directly and the Windows shell will not find the file without the full path.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

pguild

Thanks. Giving the full pathname to Wallpaper worked. You told me as soon as I posted my code. I appreciate you. ;D
www.DogTrainingPsychology.com -- "Don't wish it were easier, wish you were better."  as aphorism by Jim Rohn as quoted in the Kindle Book, GEMS OF WISDOM by Philip Seyer