WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: Secondlaw on January 02, 2019, 09:01:04 AM

Title: Run as different user
Post by: Secondlaw on January 02, 2019, 09:01:04 AM
Is there an easy way to run "CMD.EXE" with, "Run as different user" (see attached).

It seems that all of the info I'm able to find has "UAC" attached to it but that's not an issue for me. 

Thanks in advanced.
Title: Re: Run as different user
Post by: td on January 02, 2019, 09:21:22 AM
You need to provide a lot more context.  Otherwise, you leave forum members to either post a response based on a guess at what that context might be or trying to answer the same question many times.   For example, do you want to create a WinBatch script to run cmd.exe as a different user?  Which version(s) of Windows are you planning to run cmd.exe on?  Why do you think UAC does not apply to you?
Title: Re: Run as different user
Post by: Secondlaw on January 02, 2019, 09:32:30 AM
"do you want to create a WinBatch script to run cmd.exe as a different user?"
Yes!

I'd like to run "CMD.EXE" as a different user on a 64bit Win10 machine.  I've turned off UAC.
Title: Re: Run as different user
Post by: td on January 02, 2019, 11:59:47 AM
By "I've turned off UAC" do you mean you have set UAC to no admin prompt or do you mean you have edited the registry to completely disable UAC?  Note that if you have done the latter, you will not be able to run system apps like "Settings" and "Calculator" to name a few.
Title: Re: Run as different user
Post by: td on January 03, 2019, 08:04:33 AM
Should add that if you simply turned off UAC admin prompting on Windows 10, UAC considerations do apply to attempts to run as a different user.
Title: Re: Run as different user
Post by: Secondlaw on January 04, 2019, 04:56:24 AM
I've edited the registry to turn it off.

Is there a way to do this or should I look for another solution?
Title: Re: Run as different user
Post by: td on January 04, 2019, 07:51:51 AM
The RunWithLogon function is used to run an application as a different user.  Please see the Consolidated WIL Help file for details.
Title: Re: Run as different user
Post by: Secondlaw on January 04, 2019, 08:10:37 AM
PERFECT!!!!  Thank You!
Title: Re: Run as different user
Post by: td on January 10, 2019, 07:35:23 AM
In the future when you start a topic, please provide more context up front.