Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Trying to execute netsh commands at Login time

netsh wireless lan wifi login

  • Please log in to reply

#1
vinny_the_hack

vinny_the_hack

    Member

  • Member
  • PipPipPip
  • 157 posts

I am using a usb wireless network device on my windows 8 desktop to connect a laptop (and chromecast). Whenever I restart my desktop for any reason, I need to define and start my ad hoc wireless network again by opening a cmd prompt (with admin power) and issuing two commands. I did a little research and found a folder in windows to place user "startup" commands/apps, so I created a file named define_wifi.bat and placed it here:

 

"C:\Users\Melanie\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\define_wifi.bat".

 

The file contains the following:

 

netsh wlan set hostednetwork mode=allow ssid=wifinet key=wifipass

netsh start hostednetwork

 

When I log into windows (on my admin account), about 20 seconds later, I see the cmd screen appear for a split second and then disappear, so I know the file is at least "seen" by windows, but apparently, my wireless network is not defined/started. What is wrong or what can I do to troubleshoot this issue? Thanks ahead of time.

 

Note: I have a technical background, but don't know all the ins and outs of Windows.


  • 0

Advertisements


#2
SleepyDude

SleepyDude

    Trusted Helper

  • Malware Removal
  • 4,975 posts

Hi,
 
The problem is that the script running that way will not have the needed Administrator rights.

 

Also you should move the script to some other place like c:\MyScripts or something like that and add only a shortcut to "C:\Users\Melanie\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\" pointing to c:\Myscripts\define_wifi.bat then you can edit the shortcut properties and on the Advanced options put a check on the option Run as Administrator. Doing this way the script should work but you will get a security prompt every time you logon.

 

Alternatively to the shortcut you can set a task on Task Scheduler to avoid the security prompt when the script starts, you can find a guide for that here.


  • 0

#3
vinny_the_hack

vinny_the_hack

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 157 posts

Thanks, SleepyDude. I'll mull your two suggestions over and report back.


  • 0

#4
vinny_the_hack

vinny_the_hack

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 157 posts

Strange goings-on. I moved the .bat file back to my desktop, created a shortcut and moved it to the startup folder. I then set the shortcut to "run as administrator". I manually stopped the network, logged off and on and waited. There was no run window shown and no command prompt, but the network did not start.

 

While I was pondering this, I right-clicked on my .bat file and happened to notice I could just run the file as administrator right there, which I did, and after the security prompt, the network started. It seems to me trying to get it to started at Login time or scheduling it as a task is more work than it's worth. I'd just as soon just run the file from my desktop whenever I reboot.

 

Thanks for your help, without which, I might never have stumbled on/realized the easier way to do this.


  • 0

#5
SleepyDude

SleepyDude

    Trusted Helper

  • Malware Removal
  • 4,975 posts

Hi,

 

Strange goings-on. I moved the .bat file back to my desktop, created a shortcut and moved it to the startup folder. I then set the shortcut to "run as administrator". I manually stopped the network, logged off and on and waited. There was no run window shown and no command prompt, but the network did not start.

 

What happens if you click the shortcut created by opening the Start Menu > All Programs > Startup ?

 

In my opinion the Desktop isn't a good place for the Bat. If you move it for c:\windows for example you can create a shortcut on the Desktop with the option to always run as Administrator without the need of right click in case you decide to do it manually.


  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP