viewpoint-particle

Author Topic: How run a Winbatch program in "elevated" mode?  (Read 276 times)

pguild

  • Jr. Member
  • **
  • Posts: 55
  • The dog is always right!
    • MasteryLearning
How run a Winbatch program in "elevated" mode?
« on: November 18, 2022, 03:25:52 pm »
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.

ChuckC

  • Sr. Member
  • ****
  • Posts: 407
Re: How run a Winbatch program in "elevated" mode?
« Reply #1 on: November 18, 2022, 06:07:06 pm »
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

  • Tech Support
  • *****
  • Posts: 4208
    • WinBatch
Re: How run a Winbatch program in "elevated" mode?
« Reply #2 on: November 20, 2022, 08:34:08 am »
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

  • Jr. Member
  • **
  • Posts: 55
  • The dog is always right!
    • MasteryLearning
Re: How run a Winbatch program in "elevated" mode?
« Reply #3 on: December 16, 2022, 01:00:19 pm »
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")

td

  • Tech Support
  • *****
  • Posts: 4208
    • WinBatch
Re: How run a Winbatch program in "elevated" mode?
« Reply #4 on: December 16, 2022, 01:54:37 pm »
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

  • Tech Support
  • *****
  • Posts: 4208
    • WinBatch
Re: How run a Winbatch program in "elevated" mode?
« Reply #5 on: December 16, 2022, 02:34:56 pm »
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
; 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

  • Tech Support
  • *****
  • Posts: 4208
    • WinBatch
Re: How run a Winbatch program in "elevated" mode?
« Reply #6 on: December 16, 2022, 02:41:21 pm »
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

  • Jr. Member
  • **
  • Posts: 55
  • The dog is always right!
    • MasteryLearning
Re: How run a Winbatch program in "elevated" mode?
« Reply #7 on: December 20, 2022, 10:36:24 am »
Thanks. Giving the full pathname to Wallpaper worked. You told me as soon as I posted my code. I appreciate you. ;D