When I want to start a local hotspot, I normally run cmd as administrator and type the command
netsh wlan start hostednetwork . It wastes of time to run cmd and type this command. Is there any alternative way to do it using bat file?
Might be late, but save only this line into .bat file:
netsh wlan start hostednetwork
And then use any .bat to .exe converter like this one: Advanced BAT to EXE Converter OR you can use anyone else you like.
Convert it, right click on the new one, Properties -> Compatibility -> Run this program as an administrator
Double click the new .exe file, and there you go!
You need to set the hostednetwork for the first time if you haven't before using this line:
netsh wlan set hostednetwork mode=allow ssid=SSID_NAME key=PASSWORD
IFF you want to run your hostednetwork at startup:
Open Run (Windows key + R)
type: shell:startup
Then copy the .exe file you made previously in that folder.
You may need to enable "Run as an administrator" option for that program after moving it to startup folder.
Take a look into this gist, in resume just write this into a batch-File
netsh wlan set hostednetwork mode=allow ssid=SSID_NAME key=PASSWORD
netsh wlan start hostednetwork
pause
Me too, I don't want run command every create wifi, so I find a solution, that is create shortcut. It's easier than creating batch-file.
Start: netsh wlan start hostednetwork
Stop: netsh wlan stop hostednetwork
Right click shortcut / Properties / Advanced / Tick Run as administrator/ ok / Apply / ok.
You cant watch on youtube, this is tutorial video.
Related
I would like a batch file to open separate internet windows in order to keep relevant information grouped without having a ton of tabs.
I can open a single internet window doing this:
#Echo Off
start chrome.exe
exit
I can open two separate windows doing this:
#Echo Off
start chrome.exe
start chrome.exe
exit
However, as soon as I add a web link to either of these, the window will not open. Instead, a new tab is created in whatever window was open first it would seem:
#Echo Off
start chrome.exe "www.Yahoo.com"
start chrome.exe "www.Google.com"
Exit
These commands will open separate windows if there are no URLs, but they will open a new tab for the link if you include the URLs, usually in the first window that is/gets opened...
I just discovered -new-window here.
I will try that and report back.
#Echo Off
start chrome.exe -new-window "www.Yahoo.com"
start chrome.exe -new-window "www.Google.com"
Exit
This is what I needed. It opens separate windows for each without adding new tabs to a different window.
I am writing batch file to use 'netsh' command repetitive. So far I wrote this code.
#Echo Off
SET PCNAME=%COMPUTERNAME%.%USERDNSDOMAIN%
#Echo On
netsh http add urlacl url=http://%COMPUTERNAME%.%USERDNSDOMAIN%:1000/ user=everyone
Exit
When I am running this command, this runs infinitely. Even when I run only
netsh http add urlacl url=http://%COMPUTERNAME%.%USERDNSDOMAIN%:1000/ user=everyone
It's going infinitely.
What can I do to run it properly?
Filename was netsh.bat. I changed file name and its working fine
im tyring to write a bat file to ensure i am logged into a remote pc by a certain time so that some other auto processes can run on that pc.
heres where i am
cmdkey /generic:TERMSRV/server /user:**** /pass:*****
mstsc /v:server
ping 8.8.8.8 -n 10
taskkill /im mstsc.exe /f
problem im facing is that after lauching the remote pc is doesnt move to the ping until i manually close the cmd window
seems really simple, im just blanking. and if i could schedule it and save my creds in task scheduler i would, current gp doesnt allow me to.
thanks in advance.
You can call mstsc with start to run mstsc independently of the batch script.
start "" mstsc /v:server
I made a batch file with the following line
net stop audiosrv & net start audiosrv
It just flashes and closes, not actually doing the command. I think I saw something about administrator privileges in the command window but it flashed too fast to tell. What is wrong?
Create a new text file.
Then, paste the following code into it.
#echo off
net stop audiosrv
pause
net start audiosrv
pause
Save the file as a bat file.
Open the bat file as admin.
Here find a script for running a batch file as an admin
#echo off
if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
net stop audiosrv
pause
net start audiosrv
pause
A more comprehensive batch file approach:
#echo off
if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
net stop audiosrv
pause
net stop AudioEndpointBuilder
pause
net start AudioEndpointBuilder
pause
net start audiosrv
pause
The audio service is started by Windows using local system account and therefore it is not possible to stop this service without administrator privileges as command net outputs.
The solution is clicking with right (secondary) mouse button on batch file and click with left (primary) mouse button in context menu on Run as Administrator as Magoo already suggested before.
For testing a batch file just created, it is always useful to open a command prompt window and run the batch file from within this window by entering name (with path if needed) and hitting RETURN. A shortcut for opening a command prompt window can be found in Accessories menu of Windows start menu, or the command cmd.exe is executed which also opens a console window.
To help my computer boot faster, I created a simple batch file that will open the programs I want, rather than do it all on startup, when I sometimes don't want them to.
#ECHO OFF
cd "C:\Users\Aaron\Documents\Documents"
start SSS.lnk
cd "C:\Program Files (x86)\puush"
start puush.exe
cd "C:\Users\Aaron\AppData\Roaming\Google\Google Talk\"
start googletalk.exe
cd "C:\Users\Aaron\AppData\Local\Facebook\Messenger\2.1.4651.0\"
start FacebookMessenger.exe
cd "C:\Program Files\Synergy\"
start synergy.exe
cd "C:\Program Files (x86)\Skype\Phone\"
start Skype.exe
cd "C:\Program Files (x86)\Miranda IM\"
start miranda32.exe
However,
cd "C:\Users\Aaron\Documents\Documents"
start SSS.lnk
is a service that's set to Manual, and I start that myself, and it requires to be run as administrator to start. Is there anything to add in front of that to run just that as administrator?
You might wish to have a look at Runas.
Short answer: You can use runas.exe:
C:\>runas /user:<localmachinename>\administrator cmd
or
runas.exe /user:administrator "full qualified path to your exe"
For the last cmd, you can add /savecred to save the administrator's password (not that I'm saying this is a good idea).
Workaround: Create a shortcut to your script. Go to properties, shortcut, advanced. Check "run as administrator".
There you go; every time you access via shortcut it will open as administrator.
There some misunderstoods:
How to get localmachinename
There are many ways, some of them are:
a. c:\>hostname or
b. c:\>echo %computername%
You can't use runas [...] command if you don't have set password to your Windows.
1327: Logon failure: user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy restriction has been enforced.