Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Elevated command via batch file?

24 Jan 2013   #1
nigelmercier

Windows 7 Professional x64
 
 
Elevated command via batch file?

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.


My System SpecsSystem Spec
.

25 Jan 2013   #2
doubled822

Windows 7 Ultimate x64, BackTrack Linux 5 R2, Windows XP
 
 

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 System SpecsSystem Spec
25 Jan 2013   #3
Parman

Windows 7 Ultimate x64
 
 

Use the runas command.
My System SpecsSystem Spec
.


26 Jan 2013   #4
nigelmercier

Windows 7 Professional x64
 
 

Quote   Quote: Originally Posted by Parman View Post
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 System SpecsSystem Spec
26 Jan 2013   #5
Parman

Windows 7 Ultimate x64
 
 

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 System SpecsSystem Spec
26 Jan 2013   #6
chev65

Windows 7 Ult, Windows 8.1 Pro,
 
 

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 System SpecsSystem Spec
28 Jan 2013   #7
nigelmercier

Windows 7 Professional x64
 
 

Quote   Quote: Originally Posted by chev65 View Post
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 System SpecsSystem Spec
28 Jan 2013   #8
doubled822

Windows 7 Ultimate x64, BackTrack Linux 5 R2, Windows XP
 
 

Quote   Quote: Originally Posted by nigelmercier View Post
Quote   Quote: Originally Posted by Parman View Post
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 System SpecsSystem Spec
29 Jan 2013   #9
nigelmercier

Windows 7 Professional x64
 
 

Quote   Quote: Originally Posted by doubled822 View Post
Quote   Quote: Originally Posted by nigelmercier View Post
Quote   Quote: Originally Posted by Parman View Post
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 System SpecsSystem Spec
29 Jan 2013   #10
chev65

Windows 7 Ult, Windows 8.1 Pro,
 
 

Quote   Quote: Originally Posted by nigelmercier View Post
Quote   Quote: Originally Posted by chev65 View Post
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. Your Welcome.
My System SpecsSystem Spec
Reply

 Elevated command via batch file?




Thread Tools





Similar help and support threads
Thread Forum
Problem with batch file command to edit registry
reg add HTLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DontDisplayLastUserName /t REG_DWORD 00000001 /f I am trying to hide all users at logon and I know this is where you change it but for some odd reason the syntax is wrong and I can not figure it out. Can someone please...
Customization
In Need a batch file command
So, I need a command for batch files, or other things that a batch file can link to, that selects another window, say a text window(notepad) and then can be typed into. I've used the vbs scripting with Set oShell = CreateObject("WScript.Shell") oShell.AppActivate "Window name" ...
General Discussion
Batch file not waiting for command to finish before moving on
Hiya, i wasn't really sure where to put this, and i have Googled it but i can't find a reason why my batch file no longer does what it used to do. According to everything i've read, my batch should stop at IE, until i close IE, whereupon it should continue. This is how it used to behave. Here it...
Software
Issues with batch file to run MMC with elevated account
Hey all. I'm trying to create a batch file to run an MMC using an elevated account. I'm a novice when it comes to batch files, but this is what I have so far is: runas /user:domain\account "mmc C:\SuperConsole.msc" pause While I'm not including the domain or account info in this post, the...
General Discussion
programmatic way with BAT file determining if elevated command prompt
Is there any programmatic way within a BATch file of determining whether it has been started from an elevated command prompt (run as Administrator) or a normal command prompt? I note the difference between the Current Directory at start of the BATch file, but wonder if there is a better way. ...
General Discussion
Batch File - For Command??
<This post has now been solved> Hi, Sorry if this is not the place but does anyone know how to do the following? I am trying to create a batch file to search a directory for a specified file type and list it in a text file then get the batch file to read that text file and copy all the...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 22:12.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App