我从 Youtube 视频中获得了以下脚本,但我想知道将 -1 10 放入 ping 命令的目的或功能是什么。谁能帮我提供这个信息!提前致谢。
@echo off
:top
set /p "ip=Input IP or target name to ping : "
ping -n 1 %ip% | find "TTL="
ping -n 2 -1 10 127.0.0.1 >nul
goto top
我使用以下批处理来检查是否安装了 Adobe Reader。运行时,它会显示已安装程序的 REGISTRY KEY 详细信息。怎么可能不显示 REGKEY 详细信息?
REM Check file existence in REGISTRY KEY
reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe" /ve
if not errorlevel 1 (
echo Adobe Reader already installed
ping /n 6 localhost>nul 2>&1
) else (
echo Install Adobe Reader now
pause
Call "%~dp0..\Step 3 - Install Adobe Reader DC\Installer\Full_Setup_adobe_DC.bat"
)
我想将文件路径批量转换为powershell脚本。我的批处理文件路径是
Xcopy %~d0\Software\Browsers\ChromeStandaloneSetup64.exe" %userprofile%\downloads
我在powershell脚本下尝试过,但没有找到。
Copy-Item -Path "${PSScriptRoot}\Softwares\Browsers\ChromeStandaloneSetup64.exe" -Destination "$($env:USERPROFILE)\downloads"
我相信我在 Powershell 中为 %~d0 批量使用了错误的路径缩写。请帮我纠正它。谢谢。
(我的 powershell ps1 文件存储在名为 Xray 的文件夹中,但 .exe 文件存储在另一个名为 Softwares\Browsers 的文件夹中。Xray 和 Softwares 文件夹都在 USB 驱动器中)
我想在找到结果时运行该命令,但它似乎不起作用。我们的计算机名称类似于 HS-33-123-WC、HS-34-456-X 结果似乎不是我想要的。如果 %%a==WC goto dhcp 和 if %%a==X goto static 我似乎没有制作正确的脚本
REM Display the 4th group of character(s) after -
wmic computersystem get name
for /f "tokens=4 delims=-" %%a in ("%computername%") do (echo %%a && goto next)
:next
if %%a==WC goto dhcp
if %%a==X goto static
:static
echo Static
pause
goto end
:dhcp
echo This is DHCP
pause
goto end
:end @exit /b
我使用下面的脚本来激活我们的 Office 2016。有没有办法在一行中组合密钥和激活,因此在运行批处理时需要交互。
pushd %programfiles%\Microsoft Office\Office16
Echo Activate Office 2016 (64 bit)
echo. =================================
set /p key="Input Office 2016 KEY : "
echo. =================================
cscript ospp.vbs /inpkey:%key%
cscript ospp.vbs /act
@exit /b
popd
我想知道我的代码是否能够一个接一个地运行命令,而无需在激活 Windows 后单击“确定”进行交互,或者我应该在每个命令行上添加“Start /wait cmd”.....”之类的命令。
@echo off
REM Windows Activation
Echo Activate Windows
set /p key="Input Windows Key : "
slmgr /ipk %key% /ato && ^
wmic csproduct && ^
gpupdate /force
Modified
@echo off
REM Windows Activation
Echo Activate Windows
echo. =================================
set /p key="Input Windows KEY : "
echo. =================================
cscript %windir%\system32\slmgr.vbs /ato | find /i "successfully" && (goto status)
:status
Echo Check Windows Status
SetLocal EnableExtensions EnableDelayedExpansion
Set "WinVerAct="
For /f "tokens=*" %%W in ('
cscript /Nologo "C:\Windows\System32\slmgr.vbs" /xpr
') Do Set "WinVerAct=!WinVerAct! %%W"
if Not defined WinVerAct (
Echo:No response from slmgr.vbs
Exit /B 1
Echo Windows Version Activation Status:
Echo:"%WinVerAct:~1%"
wmic csproduct && ^
gpupdate /force
@exit /b
请帮助查看文件创建成功后无法打开查看的问题所在。
dim fname
fname=InputBox("Enter File Name:")
MsgBox("The File name is " & fname)
' Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const ForReading = 1
Const OpenAsASCII = 0
Const OverwriteIfExist = -1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fResultFile = objFSO.CreateTextFile(fname & ".txt", _
OverwriteIfExist, OpenAsASCII)
Set objInputFile = objFSO.OpenTextFile("iplist.txt", ForReading)
arrIpList = Split(objInputFile.ReadAll, vbCrLf)
objInputFile.Close
For l = 0 To UBound(arrIpList)
strIP = Trim(arrIpList(l))
If strIP <> "" Then
If Not IsConnectible(strIP, "", "") Then
fResultFile.WriteLine strIP & " is down"
End If
End If
Next
' Open Result file
Set inCsvSys = CreateObject("Scripting.FileSystemObject")
Set inCsv = inCsvSys.OpenTextFile(fname & ".txt")
WScript.Echo "FIle found and opened successfully"
Function IsConnectible(sHost, iPings, iTO)
' Returns True or False based on the output from ping.exe
' Works an "all" WSH versions
' sHost is a hostname or IP
' iPings is number of ping attempts
' iTO is timeout in milliseconds
' if values are set to "", then defaults below used
Const OpenAsASCII = 0
Const FailIfNotExist = 0
Const ForReading = 1
Dim oShell, oFSO, sTempFile, fFile
If iPings = "" Then iPings = 2
If iTO = "" Then iTO = 750
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTempFile = oFSO.GetSpecialFolder(2).ShortPath & "\" & oFSO.GetTempName
oShell.Run "%comspec% /c ping.exe -n " & iPings & " -w " & iTO _
& " " & sHost & ">" & sTempFile, 0 , True
Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, _
FailIfNotExist, OpenAsASCII)
Select Case InStr(fFile.ReadAll, "TTL=")
Case 0 IsConnectible = False
Case Else IsConnectible = True
End Select
fFile.Close
oFSO.DeleteFile(sTempFile)
End Function
我想知道通过批处理脚本删除了多少文件。我找到了一个脚本并对其进行了修改,但它不起作用。任何想法如何解决它。
set-location d:\testing -ErrorAction stop # Change directory
$files = get-childitem -File # Get all
the files in this directory
$folders = get-childitem -directory # Get all
the folders in this directory
$count = ($files|measure).count #
($files|measure).count gives how
# many files
are in this collection.
$countfo = ($folders|measure).count #
($files|measure).count gives how
# many files
are in this collection.
Start-Sleep -s 5
write-host "There are $($count) files to be deleted." # Write
that to the screen.
$files | remove-item # remove
the files
write-host "There are $($countfo) folders to be deleted." # Write
that to the screen.
$folders | remove-item # remove
the files
$files = get-childitem -File # Get all
the files in this directory
# after the
delete to find out how
# how many
remained.
$folders = get-childitem -directory # Get all
the folders in this directory
# after the
delete to find out how
# how many
remained.
$count2 = ($files|measure).count #
$countfinal = $count-$count2
$countfo2 = ($folders|measure).count
$countfofinal = $countfo-$countfo2
write-host "$($count2) files remained. " -NoNewline #
write-host "$($countfinal) files were deleted. " #
write-host "$($countfo2) folders remained. " -NoNewline #
write-host "$($countfofinal) folders were deleted. " #
Start-Sleep -s 5
我有一个批处理脚本来创建任务计划程序,但我想将条件添加到唤醒这台计算机以运行此任务。此任务的目的是将计算机从睡眠模式中唤醒。我已经在网上搜索了很多文章,但我找不到有关此功能的任何解决方案。任何有才华的人都可以帮助我完成这项工作。该代码只是一个简单的代码,如下所示:
schtasks /create /sc weekly /d mon,tue,wed,thu,fri /tn "Wake_Auto" /tr "%userprofile%\documents\sleeptowake\PC_Wake.cmd" /st 09:00
PC_Wake cmd 如下:
Echo Hello!
ping 127.0.0.1
exit