Run as administrator doesn't work

Hello, so I have a problem with an executable I created.

Let me start from the beginning: I'm sysadmin at a school, 2 servers. 1 server is for telephony, the other one is a windows data server, dhcp and dns server.

All notebooks used in classes are accessed by users with standard accounts.

I need to make it so that these notebooks work as wifi access points. I tried out all imaginable software and they all have one problem: the password is very easy to see or unhide. I need students to NOT know the password.

So that's what came to mind: I created a batch file with the following commands.

netsh wlan set hostednetwork mode=allow ssid=”***” key="***”
netsh wlan start hostednetwork

Open in new window


They must be executed with admin rights obviously.

I then created an exe out of the batch file using a specific software, and it works. Again, I have to execute it with admin rights.

So, the problem is, I've tried to create a shortcut with runas:

runas /user:DomainName\Administrator /savecred “C:\Path\To\Program.exe“

Open in new window


But it doesn't work as it should, it doesn't seem to actually run as admin, so nothing happens.

There are no error messages or anything.

So I was wondering, do you see something wrong in my reasoning, do you have any ideas?

Thanks.
Daniele BrunengoIT Consultant, Web DesignerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Frans BrouwerSenior Systems AdministratorCommented:
try local admin on system instead of domain admin
Daniele BrunengoIT Consultant, Web DesignerAuthor Commented:
I'll try that. I'll have to create it because I don't think there's a local admin anymore.
zalazarCommented:
As far as I know it's not possible to use runas to launch an elevated process.
https://msdn.microsoft.com/en-us/library/bb756922.aspx
quote/
Be aware that runas does not provide the ability to launch an application with an elevated access token, regardless of whether it is a standard user with privileges like a Backup Operator or an administrator. The runas command grants the user the ability to launch an application with different credentials. The best method to use to launch an application with a different account is to perform the action programmatically by using a service and not rely on the user to run the component as a different user. If your program programmatically uses the runas command, ensure that it is not intended to launch an elevated process.
/quote

An alternative would be to create a scheduled task to run the exe, and specify the user with Administrative permissions and also enable the option "Run with highest privileges".

Open the Task Scheduler
Create New Task (not basic)
Name: HostedNetwork
Select the correct user to run the task.
Select Run whether user is logged on or not
Select Run with higest privileges
Actions tab: New, browse to the exe and click OK
Conditions tab: Uncheck Start the task only if the computer is on AC power
Settings tab: Stop the task if it runs longer than: 1 hour

Add NTFS read permissions for Authenticated Users on
C:\Windows\System32\Tasks\HostedNetwork

Then create a shortcut to the scheduled task:
schtasks.exe /Run /TN "HostedNetwork"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Daniele BrunengoIT Consultant, Web DesignerAuthor Commented:
I actually didn't need the last two steps, since the exe needs to run at startup. I configured the task to run after any user's login and it works like a charm, thanks!
zalazarCommented:
Very good to hear that it works fine.
You're welcome and thanks too.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IT Administration

From novice to tech pro — start learning today.