Tag Archives: windows

for each file in batch/dos

Command line usage:

for /f %f in ('dir /b c:\') do echo %f

Batch file usage:

for /f %%f in ('dir /b c:\') do echo %%f

If the directory contains files with space in the names, you need to change the delimiter the for /f command is using. for example, you can use the pipe char.

for /f "delims=|" %%f in ('dir /b c:\') do echo %%f

If the directory name itself has a space in the name, you can use the `usebackq` option on the `for`:

for /f "usebackq delims=|" %%f in (`dir /b "c:\program files"`) do echo %%f

And if you need to use output redirection or command piping, use the escape char (`^`):

for /f "usebackq delims=|" %%f in (`dir /b "c:\program files" ^| findstr /i microsoft`) do echo %%f

Remove Adobe CS4 junk from context/explorer menu

1) Open CMD*

2) Run this commands:

regsvr32 /u "C:\Program Files\Common Files\Adobe\Adobe Drive CS4\ADFSMenu.dll"
regsvr32 /u "%programfiles%\Adobe\Acrobat 9.0\Acrobat Elements\ContextMenu.dll"

* In Windows > Vista got to Run CMD As Administrator

Install UltraVNC msi remotely using a VBS / VBScript

Hi,

To create a silent MSI for UltraVNC I have used this open source app that you can get it here: UltraVNC MSI Creator

To create the MSI just follow the instructions is plain and simple.

Now the script so you can remotly install on any PC you got administrative privileges:

 Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strComputer = InputBox("Writte down the target computer","UltraVNC Remote INSTALL","Nomed do Computador", 50, 50)
Const UVNCPath = "\\yourultravncpath\UltraVNC.msi"
Const Overwrite = True
wsLocation = "\\" & strComputer & "\c$\Windows\Temp\"

if strComputer = "" then
	WScript.Quit
end if

if Ping(strComputer) then
	objFSO.CopyFile UVNCPath, wsLocation ,Overwrite
else
	msgbox("Can't reach the target computer, sorry!")
	WScript.Quit
end if

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objSoftware = objWMIService.Get("Win32_Product")
errReturn = objSoftware.Install("C:\Windows\Temp\ultravnc.msi",,True)

if errReturn = 0 then
	msgbox("Yupii, installed with success.")
	else
	msgbox("Can't install, sorry!")
end if

Function Ping(PC)
	Set objWshScriptExec = objShell.Exec("C:\WINDOWS\system32\ping.exe " & PC)
	Set objStdOut = objWshScriptExec.StdOut

	awake=False
	Do Until objStdOut.AtEndOfStream
		strLine = objStdOut.ReadLine
		awake = awake Or InStr(LCase(strLine), "bytes=") > 0
	Loop
	Ping = awake
End Function

Tail for windows

Here is a great tools to follow those txt log files that you may find on windows

The download page is: tailforwin32

Some files that could be usefull to check with tail:

c:\WINDOWS\WindowsUpdate.log

Follow this one to know, for example, if your computer is connected to a WSUS server for updates

C:\Program Files\Exchsrvr\yourservername.log\*.log

This one is useful since exchange server does not provide a useful (at least that i’m aware) way to check in real time incoming mails.

Remote shutdown Windows from Linux

Just run the following command:

net rpc SHUTDOWN -C "enter a comment to display at shutdown" -f -I x.x.x.x -U username%password

where x.x.x.x is the ip address.

To know what machines are on in a particular subnet just nmap it, like this:

nmap -sP 192.168.5.0/24 | cut -d " " -f2 > lixo.txt

And with the lixo.txt you can cicle the computers and shut them down, just run this:

for i in $(cat lixo.txt);do net rpc SHUTDOWN  -f -I $i -U user%password; done