What am I doing wrong here? I'm trying to run "program.exe" in an elevated command prompt, either by the localadmin or by domain account. Also, is it possible to run this as one file instead of two?
CLS
@ECHO OFF
ECHO Press 1 to login as local admin.
SET /P id=Enter ID: %=%
IF %id%==1 GOTO LOCALADMIN
ELSE GOTO USER
:LOCALADMIN
RUNAS /USER:%COMPUTERNAME%\Administrator program.exe
:USER
RUNAS /USER:DOMAIN\%id% program.exe
Noob help
Moderator: DosItHelp
Re: Noob help
Code: Select all
@ECHO OFF
cls
ECHO Press 1 to login as local admin.
SET /P id=Enter ID:
IF %id%==1 (
RUNAS /USER:%COMPUTERNAME%\Administrator program.exe
) else (
RUNAS /USER:DOMAIN\%id% program.exe
)
-
- Posts: 2
- Joined: 31 Jan 2014 09:15
Re: Noob help
Thank you! Do you know if there is any way to run this from a network drive? It seems I can only run it locally. Also, is there any way to make it as one file instead of having two?
Re: Noob help
digitalwaffles wrote:Thank you! Do you know if there is any way to run this from a network drive? It seems I can only run it locally.
Have no idea. The majority of my batch files sit out on a network drive and run just fine.
digitalwaffles wrote:Also, is there any way to make it as one file instead of having two?
Not sure what you mean. It is one batch file. Why are you saying it is two?
Re: Noob help
Hi,
I'm only borrowing for illustration purposes what Squashman wrote; good line of code too
now, if you want to launch from a network share, i.e. by placing this batch script on a network share, you can modify the script which Squashman wrote .. .
I'm only borrowing for illustration purposes what Squashman wrote; good line of code too

@ECHO OFF
cls
ECHO Press 1 to login as local admin.
SET /P id=Enter ID:
IF %id%==1 (
RUNAS /USER:%COMPUTERNAME%\Administrator program.exe
) else (
RUNAS /USER:DOMAIN\%id% program.exe
)
now, if you want to launch from a network share, i.e. by placing this batch script on a network share, you can modify the script which Squashman wrote .. .
@ECHO OFF
cls
ECHO Press 1 to login as local admin.
SET /P id=Enter ID:
IF %id%==1 (
RUNAS /USER:%COMPUTERNAME%\Administrator c:\program files\program.exe
) else (
RUNAS /USER:DOMAIN\%id% c:\program files\program.exe
)
[/code]
c:\program files\program.exe is the actual path on the immediate local computer that has whatever program that is installed.
Now, for Pressing 1, if 1 isn't pressed the default command execution would be:Code: Select all
RUNAS /USER:DOMAIN\%id% c:\program files\program.exe
does that help simplify the matter?
v/r Booga73