Writing to WMIC with elevated permissions

Hi all,
Has anyone had any luck writing to WMIC with elevated permissions?

I’m trying to update a compter name using:

WMIC ComputerSystem where Name=‘COMPUTERNAME’ call Rename Name=‘NewName’

I’ve tried using @Wayne_Golding 's excellent ExecuteWithUAC method but can’t seem to get the syntax right.

Just a heads up:

https://docs.microsoft.com/en-us/windows/deployment/planning/windows-10-deprecated-features

3rd item down is the mention of WMIC command line tool, you might want to use PowerShell instead

PowerShell Rename Computer

Thanks for this. Didn’t catch this one!

I actually figured out the syntax after lots of head scratching. I wonder if we’ll see support for powershell in Xojo?

I just ran this on my Win10 20H2 machine and got back the expected results

Var myShell As New Shell

myShell.Execute(“powershell.exe get-help”)
MessageBox(myShell.Result)

Have not tried setting anything but found this:
Xojo calling PowerShell

1 Like

Hi James,

When I wrote the book on Xojo WMIC, I found that there were two ways to run with elevated permissions:

  1. Create a shortcut that runs the executable with elevated permissions
  2. Create an installer which installs the program with elevated conditions, so that normal execution of the program does not require elevation.

This has been a while ago since I wrote the book, and things may have changed since then.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.