1

We're having an issue with our Mobile Broadband modem reconnecting after a drop. The issue has been elevated but a solution may take a while. A quick work around we found is disabling and re-enabling the device, however the security settings are such that our users can't enable/disable network adapters in Network Connections.

I created a batch file to handle the disable/enable but would like it to self-elevate for a non-Admin user. Even if I have to hardcode a local admin account into the file and convert it into an executable to hide the code. Here's what I have so far:

@echo off
echo Please wait while the Sprint modem is reset...
wmic path win32_networkadapter where name="Sierra Wireless Mobile Broadband Network Adapter" call disable
timeout /t 5 /nobreak
wmic path win32_networkadapter where name="Sierra Wireless Mobile Broadband Network Adapter" call enable

This works perfectly if I chose Run As: Admin. I really appreciate any and all help.

NickMasa
  • 13
  • 2
  • possible duplicate of [automatically running a batch file as an administrator](http://stackoverflow.com/questions/18755553/automatically-running-a-batch-file-as-an-administrator) – unclemeat Jan 15 '15 at 03:21

1 Answers1

1

I've had a similar problem and solved it with the help of the windows task scheduler.

  1. Create a new task within the scheduler which simply runs the bat file.
  2. Select a an admin user as the acount to run the task with.
  3. Enter the password (here is the big advantage - you don't need to store it in some script as plain text)
  4. Create another bat file with the following content: schtasks /Run /TN <taskname>
  5. Run the new bat file.

If this doesn't work, it might be because of the user nither has permission to run tasks. In this case you'll still have to store the credentials as plain text but

schtasks /Run /U <username> /P <password> /TN <taskname>

will do the trick.

MichaelS
  • 5,941
  • 6
  • 31
  • 46
  • Excellent! A friend suggested using scheduler as well, but I couldn't figure out what he meant. Thank you! – NickMasa Jan 15 '15 at 20:52