Archivi categoria: Windows

Windows: creare un file “vuoto” con dimensioni specifiche

Può essere utile avere dei file “vuoti” di dimensione specifica per eseguire dei test.

Su sistemi Windows, è possibile utilizzare il tool fsutil:

fsutil file createnew nomefile byte_size

 

Esempio 1: creare un file da 1 Megabyte:

fsutil file createnew c:\temp\%I-1MB_file.txt 1048576

Esempio 2: creare 10 file da 1 MB

for /L %I in (1,1,10) do fsutil file createnew c:\temp\%I-1MB_file_test.bin 1048576


Per approfondimenti sul tool FSUtil: https://ss64.com/nt/fsutil.html

Script Reset Windows Update Agent

Fonte: http://gallery.technet.microsoft.com/scriptcenter/Dos-Command-Line-Batch-to-fb07b159

@echo off 
cls 

REM ================================================================================== 
REM DESCRIPTION    : This script resets all of Windows Update Agent settings. 
REM AUTHOR         : Luca Fabbri 
REM VERSION HISTORY: 1.2 - Stop SMS Host Agent (SCCM Client) Service added 
REM                  1.0 - Start 
REM ================================================================================== 

@echo 1. Stopping Automatic Updates, BITS and SMS Host Agent Services... 
net stop wuauserv 
net stop bits  
net stop ccmexec 

@echo 2. Deleting AU cache folder and log file... 
del /f /q %SystemRoot%WindowsUpdate.log 
del /f /s /q %SystemRoot%SoftwareDistribution*.* 
REM @echo 2. Renaming AU cache folder and log file... 
REM ren %SystemRoot%WindowsUpdate.log %SystemRoot%WindowsUpdate.bak 
REM ren %SystemRoot%SoftwareDistribution %SystemRoot%SoftwareDistribution.bak 

@echo 3. Re-registering DLL files... 
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32atl.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32jscript.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32msxml3.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32softpub.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32wuapi.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32wuaueng.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32wuaueng1.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32wucltui.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32wups.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32wups2.dll  
%SystemRoot%system32regsvr32.exe /s %SystemRoot%system32wuweb.dll 

@echo 4. Removing WSUS Client Id... 
REG DELETE "HKLMSOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate" /v AccountDomainSid /f 
REG DELETE "HKLMSOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate" /v PingID /f 
REG DELETE "HKLMSOFTWAREMicrosoftWindowsCurrentVersionWindowsUpdate" /v SusClientId /f 

@echo 5. Starting Automatic Updates, BITS and SMS Host Agent Services... 
net start ccmexec 
net start bits 
net start wuauserv 

@echo 6. Forcing AU discovery... 
wuauclt /resetauthorization /detectnow

Killare un servizio in pending

Recuperare il PID del servizio:

sc queryex “nome.del.servizio” – l’output sarà simile a questo:
SERVICE_NAME: nome.del.servizio
TYPE               : 10  WIN32_OWN_PROCESS
STATE              : 3  STOP_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE    : 0  (0x0)
SERVICE_EXIT_CODE  : 0  (0x0)
CHECKPOINT         : 0x3
WAIT_HINT          : 0x7530
PID                : Xxxx
FLAGS              :

eseguire:

taskkill /PID Xxxx /F

🙂