Windows

 Admin privileges

At times your account esp. on office laptops directly don't have admin privileges. So you can not do lots of tasks which are restricted to admins, esp the configuration settings like editing hosts file, changing proxy settings etc.. But there will be a way to launch application( notepad, browser)  as an administrator and then you can do the restricted activities.   Click Windows(Left Bottom Corner of Screen ) Icon  -> Search Programs and Files -> Type the app name and you will see one option of running the app as Administrator ( if you were assigned that  privilege )

How to find what is running at a port

netstat - o -b -a   ( you will need to run command as admin , you can always run the cmd.exe as Administrator , provided you given that privilege ) 

WinSCP batch scripts

You can write winscp script to run in non-interactive mode.  There are two good articles on this topic.

http://www.robvanderwoude.com/ftp.php
https://winscp.net/eng/docs/scripting

We created a script based on second article above and script looked like the following:

"C:\Program Files (x86)\WinSCP\winscp.com" /ini=nul /script=putscript.txt


putscript.txt  is given below
---------------------
open username:pass@1@hostname.domain
option transfer binary
Put   \srcdir\TEST_SFTP\Test.csv /destdir
close
-------------------

it was throwing  hostkey verification related error.  you need to pass '-hostkey="xx:xx....:xx"'   argument also  in the open command.  See below for example.

Finding Large Files in Windows

Go the directory where you want to search large files and in the search box in top right corner type  size:gigantic  , you will see all the files above 128 MB. 


Changing all the files in directory to smallcase

https://superuser.com/questions/65302/is-there-a-way-to-batch-rename-files-to-lowercase


for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "%f")

WinSCP

"C:\Program Files (x86) )\WinSCP\WinSCP.com"  /ini=nul /script=script.txt

--------script.txt: begin ---------------
open sftp://username:password#@server.doamin.com/  -hostkey="ssh-rsa 2048 xx:xx:xx:......xx"
cd /first/second/third/source
lcd D:\Users\gbairwa\workspace\target
get  relative/path/*.scala  relative\path\
close
exit
------------end--------

Robocopy - Utility to sync to directory trees on Windows. This can also be used for comparing the directories without actually copying. See below 

robocopy Dir1 Dir2  /e /l /ns /njs /njh /ndl /fp /log:reconcile.txt


While you can figure out which files differ, it is not clear how you can see the actual differences. 

Below scripts will try to find actual differences in the two directory trees assuming both have same contents.


ECHO OFF
SETLOCAL EnableDelayedExpansion

CD DIR1 

//assume the number of characters in DIR1 starting is <DIR1LEN>

FOR /R %%I IN (*.scala) DO (
   REM ECHO %%I
   SET  xname=%%I
   SET  xname=!xname:~<DIR1LEN>!
   ECHO !xname!
   FC DIR1\!xname!   DIR2\!xname!

)

Installing Chrome using PowerShell scripts

https://www.snel.com/support/install-chrome-in-windows-server/

As per the link above, run following Powershell script as an Administrator. 

$LocalTempDir = $env:TEMP; $ChromeInstaller = "ChromeInstaller.exe"; (new-object System.Net.WebClient).DownloadFile('http://dl.google.com/chrome/install/375.126/chrome_installer.exe', "$LocalTempDir\$ChromeInstaller"); & "$LocalTempDir\$ChromeInstaller" /silent /install; $Process2Monitor = "ChromeInstaller"; Do { $ProcessesFound = Get-Process | ?{$Process2Monitor -contains $_.Name} | Select-Object -ExpandProperty Name; If ($ProcessesFound) { "Still running: $($ProcessesFound -join ', ')" | Write-Host; Start-Sleep -Seconds 2 } else { rm "$LocalTempDir\$ChromeInstaller" -ErrorAction SilentlyContinue -Verbose } } Until (!$ProcessesFound)

It is important that you run the script as Administrator or it won't work.  You should see the output similar to the screenshot below. Multiple lines starting with "still running...."



Comments

Popular posts from this blog

SQL

Analytics

HIVE