Windows, batch file time condition - windows

okay, so here is the case,
i would like to create a batch file, and run it and it will run until a certain time, and then it will execute the commands: ie.
if time = 18:00
netsh interface set interface "Wireless Network Connection" DISABLED
goto end
end:
close
like that?

You can use "at"
at 18:00 netsh interface set interface "Wireless Network Connection" DISABLED

Related

How to turn on Wi-Fi Software radio status with PowerShell

-EDITED- Solved here:
https://superuser.com/questions/1698403/how-to-turn-on-or-off-wi-fi-software-radio-status-with-powershell
Any help how can I turn on/off the software radio status on Windows 11?
This is the status of my Wi-Fi:
Netsh WLAN show interfaces
There is 1 interface on the system:
Name : Wi-Fi
Description : Killer Wireless-n/a/ac Wireless Network Adapter
GUID : xx
Physical address : xx
Interface type : Primary
State : disconnected
Radio status : Hardware On
Software Off
Hosted network status : Not available
This is the setting in Windows 11:
Here's some PS code to do the trick:
#Disable Network?
Try {
$NICs = Get-NetAdapter -Name * |
Where-Object {$_.Status -eq "Up" -and
$_.InterfaceName -like "*wireless*"} |
disable-NetAdapter -Confirm:$True
}
Catch [System.Management.Automation.CommandNotFoundException] {
"Get-NetAdapter CmdLet NOT available."
}
Notes:
If you want to disable regardless of the Status eliminate the first test in the Where-Object clause.
If you don't want to confirm turning it off replace -Confirm:$True w/ -Confirm:$False.
This code will disable ALL wi-fi adapters but could be adjusted to do only select ones.
I've been using this in a standard batch file:
explorer ms-settings:network-wifi
ping localhost > nul
:VBSDynamicBuild
SET TempVBSFile=%tmp%\~tmpSendKeysTemp.vbs
IF EXIST "%TempVBSFile%" DEL /F /Q "%TempVBSFile%"
ECHO Set WshShell =
WScript.CreateObject("WScript.Shell")>>"%TempVBSFile%"
ECHO WshShell.SendKeys "{TAB}">>"%TempVBSFile%"
ECHO WshShell.SendKeys " ">>"%TempVBSFile%"
CSCRIPT //nologo "%TempVBSFile%"
It basically opens up the "System", "Network & internet" window and toggles the WiFi on/off button. Run the batch file once to toggle it to the other state, and run the batch file again to toggle it back. I use the ping to delay the running of the script until after the "Network & internet" window has opened.

Typepref command gives no valid counters when running remote command

I am stuck badly into this.
I am trying to execute following batch command which runs successfully on my system present on same network as remote server,
typeperf "\192.168.1.247\Processor(_Total)\% Processor Time" -sc 2
But if I try to run the same command on another remote server present on same network,
typeperf "\192.168.1.241\Processor(_Total)\% Processor Time" -sc 2
this gives me Error: No valid counters.
Please let me know what could be the issue and what could be the possible solution to this.
Regards,
Suvojit
Try refreshing WMI with this command:
winmgmt /resyncperf & wmiadap /f
Make sure that the WMI service is running, or restart it:
net start winmgmt
Run this command to ensure that the disable key doesnt exist, or its value is 0 if it exists.
REG query HKLM\SYSTEM\CurrentControlSet\Services\PerfProc\Performance /v "Disable Performance Counters"
Try rebuilding the performance registry with the LODCTR /R command.
If nothing else works, you can try to manually rebuild Performance Counter library values as a last resort.

how to sync windows time from a ntp time server in command

I am working on windows 7. I can sync time of win7 from a ntp linux server manually. How can I do that in command prompt. So I can run it on windows startup. And windows task plan not work for me. The time should be like this:
Linux server --> windows 7.
Any one knows that? Thank you. I can read msdn.
net stop w32time
w32tm /config /syncfromflags:manual /manualpeerlist:"0.it.pool.ntp.org 1.it.pool.ntp.org 2.it.pool.ntp.org 3.it.pool.ntp.org"
net start w32time
w32tm /config /update
w32tm /resync /rediscover
.BAT Sample File: https://gist.github.com/thedom85/dbeb58627adfb3d5c3af
I also recommend this program: http://www.timesynctool.com/
Use net time
net time \\timesrv /set /yes
after your comment try this one in evelated prompt :
w32tm /config /update /manualpeerlist:yourtimerserver
If you just need to resync windows time, open an elevated command prompt and type:
w32tm /resync
C:\WINDOWS\system32>w32tm /resync
Sending resync command to local computer
The command completed successfully.
While the w32tm /resync in theory does the job, it only does so under certain conditions. When "down to the millisecond" matters, however, I found that Windows wouldn't actually make the adjustment; as if "oh, I'm off by 2.5 seconds, close enough bro, nothing to see or do here".
In order to truly force the resync (Windows 7):
Control Panel -> Date and Time
"Change date and time..." (requires Admin privileges)
Add or Subtract a few minutes (I used -5 minutes)
Run "cmd.exe" as administrator
w32tm /resync
Visually check that the seconds in the "Date and Time" control panel are ticking at the same time as your authoritative clock(s). (I used watch -n 0.1 date on a Linux machine on the network that I had SSH'd over into)
--- Rapid Method ---
Run "cmd.exe" as administrator
net start w32time (Time Service must be running)
time 8 (where 8 may be replaced by any 'hour' value, presumably 0-23)
w32tm /resync
Jump to 3, as needed.

How To Use .VBS to create WiFi HotSpot "General Spcific"

I am fairly new at .VBS and I've hit a bump. I'm trying to create a script that will allow me to automatically create a hotspot from any laptop, that the program is opened on. The bump I hit is that I cant find a way to automatically obtain the username#domain from command prompt and turned into a variable to be later injected into the coding. This is what I have so far:
msgbox("Close Me And Run As Administrator")
name=inputbox("Set SSID (WiFi Name)")
pass=inputbox("Password For WiFi")
strCmd="net wlan set hostnetwork mode=allow ssid=name key=pass"
set objShell=CrateObject("wscript.shell")
objShell.Run runas /user: "strCmd" 'this is why I need to figure out how to store and inject those variables
strCMd="net wlan set hostnetwork mode=allow ssid=name key=pass"
set objShell=CrateObject("wscript.shell")
objShell.Run runas /user: "strCMd"
and then the rest is just msgbox telling them how to finish if they want to set up file sharing (i.e. xbox, ps3 or other computers on network)
A little search on Google and I got this: http://www.robvanderwoude.com/vbstech_network_names_domain.php

Executing multiple command in command prompt using vbscript

I'm just a lurker and wondering if I can create a vbscript that can run command prompt together with the other command that I want to type in command prompt.
Here's what I want to do:
I want to create a wifi hotspot using command prompt with this command;
`netsh wlan set hostednetwork mode=allow ssid=NAME key=PASSWORD
netsh wlan start hostednetwork'
and another thing, can anyone helped me how can i share my network using command prompt to make my laptop wifi hotspot?
You want the "Shell" object to run commands:
strText="netsh wlan set hostednetwork mode=allow ssid=NAME key=PASSWORD"
Set shll = Wscript.CreateObject("Wscript.Shell")
Return = shll.Run(strText, 1, TRUE)
you can add as many "shll.run" commands as you need to - the TRUE flag above will make VBScript wait for the command to finish before continuing the script.
You would be better off looking at Powershell for sharing network connections.

Resources