Solved Elevated command via batch file?

nigelmercier

New member
Member
Local time
3:26 PM
Messages
78
I've set up a Virtual Router as in this page, but what it doesn't tell you is that you need to re-run the elevated command netsh wlan start hostednetwork every time the computer boots or comes out of standby.

Is there a way to run an elevated command via a batch file?

Later ... I've just found a similar tutorial here on W7F, and this mentions running batch files as administrator. However, I want to set this up for a novice user to use.
 
Last edited:

My Computer

Computer Manufacturer/Model Number
Homebrew
OS
Windows 7 Professional x64
CPU
Intel Core i5-2500K @ 3.3GHz
Motherboard
Fatal1ty P67 Professional
Memory
8GB
Graphics Card(s)
Zotac ZONE GeForce GT 240 1GB [ZT-20404-20L]
Sound Card
On board
Monitor(s) Displays
2x Samsung SyncMaster 203B
Screen Resolution
1400 x 1050
Case
CoolerMaster Elite
Cooling
Zalman
Keyboard
Microsoft Natural Wireless Ergonomic 7000
Mouse
Microsoft Natural Wireless Laser 7000
I can think of one way---but I recommend disabling standby functionality on this machine. Since it will essentially be your wireless router, you're going to want it running most of the time.

1. Start > Run
2. type gpedit.msc
3. Under Computer Configuration, select Windows Settings.
4. Click on Scripts, and then Startup Scripts.
5. From here you can add your batch file, and it will run under the SYSTEM account when the computer boots up, and should be good to go.

Let us know how it works out!
 

My Computer

Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate x64, BackTrack Linux 5 R2, Windows XP
CPU
Intel Core i7 920 OC to 3.6GHz
Motherboard
ASUS P6T Deluxe V2
Memory
Corsair 6GB DDR3
Graphics Card(s)
ATI Radeon 4890
Monitor(s) Displays
ASUS 23"
Screen Resolution
1920x1080
Hard Drives
150GB Velociraptor
640GB
PSU
Corsair 850w
Case
CoolerMaster HAF932
Cooling
CoolerMaster V8
Internet Speed
30Mbps
Use the runas command.
I know I can right click the batch file and use Run As Administrator ... but that is too complicated for the user. The Run As Administrator option is greyed out on the batch file properties.

The batch file can't be run until the network is connected, so it needs to be manual.
 

My Computer

Computer Manufacturer/Model Number
Homebrew
OS
Windows 7 Professional x64
CPU
Intel Core i5-2500K @ 3.3GHz
Motherboard
Fatal1ty P67 Professional
Memory
8GB
Graphics Card(s)
Zotac ZONE GeForce GT 240 1GB [ZT-20404-20L]
Sound Card
On board
Monitor(s) Displays
2x Samsung SyncMaster 203B
Screen Resolution
1400 x 1050
Case
CoolerMaster Elite
Cooling
Zalman
Keyboard
Microsoft Natural Wireless Ergonomic 7000
Mouse
Microsoft Natural Wireless Laser 7000
I meant one of two thing.

You can put the runas in the batch file to run the command.

Runas (place username and password) (command)

Or you can create two batch files and use the runas command to call (run) the second batch file.

You can also use the task scheduler and run it as admin when the pc boots up or at logon.
 

My Computer

OS
Windows 7 Ultimate x64
I'm pretty sure that the connectify software for creating a hosted wireless network, can be set to start up automatically when the machine is started. This should be easier for a Novice.

Connectify Hotspot - Connectify
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home built
OS
Windows 7 Ult, Windows 8.1 Pro,
CPU
Q9650-4.275GHz, E8600 4.5GHz, E6750-3.8GHz
Motherboard
Evga 780i FTW
Memory
G.Skill PC2 9600 1200Mhz 5 5 5 15 2T
Graphics Card(s)
GTX480
Sound Card
Asus Xonar D2
Monitor(s) Displays
HannsG
Screen Resolution
1680X1050
Hard Drives
GSkill Phoenix Pro 120GB SSD
PSU
ThermalTake Toughpower 1000Watt modular
Case
ThermalTake XaserV
Cooling
Xigmatek S1283
Keyboard
Logitech G15
Mouse
Logitech G9
Internet Speed
T1
I'm pretty sure that the connectify software for creating a hosted wireless network, can be set to start up automatically when the machine is started. This should be easier for a Novice.

Connectify Hotspot - Connectify

It's a novice using it, not setting it up, so Connectify is a bit OTT.
 

My Computer

Computer Manufacturer/Model Number
Homebrew
OS
Windows 7 Professional x64
CPU
Intel Core i5-2500K @ 3.3GHz
Motherboard
Fatal1ty P67 Professional
Memory
8GB
Graphics Card(s)
Zotac ZONE GeForce GT 240 1GB [ZT-20404-20L]
Sound Card
On board
Monitor(s) Displays
2x Samsung SyncMaster 203B
Screen Resolution
1400 x 1050
Case
CoolerMaster Elite
Cooling
Zalman
Keyboard
Microsoft Natural Wireless Ergonomic 7000
Mouse
Microsoft Natural Wireless Laser 7000
Use the runas command.
I know I can right click the batch file and use Run As Administrator ... but that is too complicated for the user. The Run As Administrator option is greyed out on the batch file properties.

The batch file can't be run until the network is connected, so it needs to be manual.

Have you looked into my suggestion? You could also set this as a login script as opposed to a startup script, if you're concerned about the network not being active before it runs.
 

My Computer

Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate x64, BackTrack Linux 5 R2, Windows XP
CPU
Intel Core i7 920 OC to 3.6GHz
Motherboard
ASUS P6T Deluxe V2
Memory
Corsair 6GB DDR3
Graphics Card(s)
ATI Radeon 4890
Monitor(s) Displays
ASUS 23"
Screen Resolution
1920x1080
Hard Drives
150GB Velociraptor
640GB
PSU
Corsair 850w
Case
CoolerMaster HAF932
Cooling
CoolerMaster V8
Internet Speed
30Mbps
Use the runas command.
I know I can right click the batch file and use Run As Administrator ... but that is too complicated for the user. The Run As Administrator option is greyed out on the batch file properties.

The batch file can't be run until the network is connected, so it needs to be manual.

Have you looked into my suggestion? You could also set this as a login script as opposed to a startup script, if you're concerned about the network not being active before it runs.

The startup needs to be manual, or when the Wi-Fi has fully connected, it is only valid occasionally.
 

My Computer

Computer Manufacturer/Model Number
Homebrew
OS
Windows 7 Professional x64
CPU
Intel Core i5-2500K @ 3.3GHz
Motherboard
Fatal1ty P67 Professional
Memory
8GB
Graphics Card(s)
Zotac ZONE GeForce GT 240 1GB [ZT-20404-20L]
Sound Card
On board
Monitor(s) Displays
2x Samsung SyncMaster 203B
Screen Resolution
1400 x 1050
Case
CoolerMaster Elite
Cooling
Zalman
Keyboard
Microsoft Natural Wireless Ergonomic 7000
Mouse
Microsoft Natural Wireless Laser 7000

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Home built
OS
Windows 7 Ult, Windows 8.1 Pro,
CPU
Q9650-4.275GHz, E8600 4.5GHz, E6750-3.8GHz
Motherboard
Evga 780i FTW
Memory
G.Skill PC2 9600 1200Mhz 5 5 5 15 2T
Graphics Card(s)
GTX480
Sound Card
Asus Xonar D2
Monitor(s) Displays
HannsG
Screen Resolution
1680X1050
Hard Drives
GSkill Phoenix Pro 120GB SSD
PSU
ThermalTake Toughpower 1000Watt modular
Case
ThermalTake XaserV
Cooling
Xigmatek S1283
Keyboard
Logitech G15
Mouse
Logitech G9
Internet Speed
T1
I'm pretty sure that the connectify software for creating a hosted wireless network, can be set to start up automatically when the machine is started. This should be easier for a Novice.

Connectify Hotspot - Connectify

It's a novice using it, not setting it up, so Connectify is a bit OTT.

That's as easy as it's going to get.

Yes, but Connectify will run automatically, I don't want it to do this.

This is all a red herring anyway, perhaps I gave too much detail or posted in the wrong forum. The bottom line is that I want to run an elevated command via a batch file, without going via the right click menu. It would be simple if the batch file had a tick box for Run as Administrator, but it is greyed out.
 

My Computer

Computer Manufacturer/Model Number
Homebrew
OS
Windows 7 Professional x64
CPU
Intel Core i5-2500K @ 3.3GHz
Motherboard
Fatal1ty P67 Professional
Memory
8GB
Graphics Card(s)
Zotac ZONE GeForce GT 240 1GB [ZT-20404-20L]
Sound Card
On board
Monitor(s) Displays
2x Samsung SyncMaster 203B
Screen Resolution
1400 x 1050
Case
CoolerMaster Elite
Cooling
Zalman
Keyboard
Microsoft Natural Wireless Ergonomic 7000
Mouse
Microsoft Natural Wireless Laser 7000
Maybe if you describe the situation a little better we could help. It's not really making sense to me personally...you have a user that occasionally wants to use a certain PC, and this certain PC is going to act as a "virtual" router? To serve other PC's connections? Does this user know that their PC is intended to function this way?

Wouldn't it be easier just to buy an actual router?
 

My Computer

Computer Manufacturer/Model Number
Custom Build
OS
Windows 7 Ultimate x64, BackTrack Linux 5 R2, Windows XP
CPU
Intel Core i7 920 OC to 3.6GHz
Motherboard
ASUS P6T Deluxe V2
Memory
Corsair 6GB DDR3
Graphics Card(s)
ATI Radeon 4890
Monitor(s) Displays
ASUS 23"
Screen Resolution
1920x1080
Hard Drives
150GB Velociraptor
640GB
PSU
Corsair 850w
Case
CoolerMaster HAF932
Cooling
CoolerMaster V8
Internet Speed
30Mbps
Strange how some folks question ones reasons for asking a question. :rolleyes:

All sorted, the trick was to create a shortcut to the batch file, and select the Run as Administrator tick box for that. Now when this computer has an active Wi-Fi connection, it can be shared with local iPads etc.

[Later] Found this trick is already mentioned on the W7F, see here post #15, with another method at post #16
 

My Computer

Computer Manufacturer/Model Number
Homebrew
OS
Windows 7 Professional x64
CPU
Intel Core i5-2500K @ 3.3GHz
Motherboard
Fatal1ty P67 Professional
Memory
8GB
Graphics Card(s)
Zotac ZONE GeForce GT 240 1GB [ZT-20404-20L]
Sound Card
On board
Monitor(s) Displays
2x Samsung SyncMaster 203B
Screen Resolution
1400 x 1050
Case
CoolerMaster Elite
Cooling
Zalman
Keyboard
Microsoft Natural Wireless Ergonomic 7000
Mouse
Microsoft Natural Wireless Laser 7000
Back
Top