Windows batch

From bernie's
Jump to navigation Jump to search

Add list of filenames to comma separated text file

@echo off
del f.txt
set file=f.txt
for /f "delims=" %%a in ('dir /b/s *.pdf') do (
    echo | set /p=%%~na, >> f.txt
)

Right Click to add folder to system PATH (windows)

  • Save this as a batch file somewhere (without spaces in folder+file name! I think. Fuck Windows!)
  • Shortcut to it in the sendto folder (to go directly to the sendto folder, write shell:sendto in Win-R (run) menu)
  • Edit the shortcut advanced properties to run as Administrator
@echo off
echo _____envs_________________________________________________________________
for %%G in ("%path:;=" "%") do @echo %%G
echo __________________________________________________________________________
echo adding %1 to path

set NEW_PATH=%1
set NEW_PATH=%NEW_PATH:"=%
set NEW_PATH_VAR="%PATH%;%NEW_PATH%"


SET /P M=1 to add to user PATH, 2 for system PATH, 3 for Windows Dialog, 4 to cancel : 
IF %M%==1 GOTO userV
IF %M%==2 GOTO systemV
IF %M%==3 GOTO windowsD
IF %M%==4 GOTO EOF

:userV
setx PATH %NEW_PATH_VAR%
goto EOF
:systemV
setx /M PATH %NEW_PATH_VAR%
goto EOF
:windowsD
rundll32.exe sysdm.cpl,EditEnvironmentVariables
goto EOF

Parse folder with image sequence(s) to mp4 videos with ffmpeg (tested on windows)

Sequence of images to h264 / h265

U8ZZm6u.gif

  • should be py2/3 compatible, haven't tried a lot of cases
  • sometimes python (.py) files won't work directly in the shell:sendto folder. You instead need to create a .bat file and point to a python executable like so (remember to add the current file variable if your python script needs it like I do)
  • Will ask for a ffmpeg exe on first run, saves the path as a pickle in your userprofile.
@echo off
C:\Users\Me\AppData\Local\Programs\Python\Python39\python.exe %userprofile%\Documents\h264.py "%~f1"
# the h264.py file
#
# windows, save into sendto folder so you can access with right click > send to
# to access the folder, write shell:sendto in Win-R (run) menu

debug = False

#older/other options, things to note, I moved to h265/hvec because I had malloc issues. 64bit problem ? RAM problems ? I dunno.

#ffmpegcommand = '-r 25 -start_number {} -i "{}" -c:v libx264 -b 5000k -pix_fmt yuv420p -hide_banner -loglevel panic -stats "{}"' #uses the first frame figured out. Doesnt work well with non padded sequences
#motion jpeg
#ffmpegcommand = '-r 25 -start_number {} -i "{}" -c:v mjpeg -qscale:v 1 -vendor ap10 -pix_fmt yuvj422p -hide_banner -loglevel panic -stats "{}"'

ffmpegcommand = '-r 25 -i "{}" -c:v libx265 -b 5000k -pix_fmt yuv420p -hide_banner -loglevel panic -stats "{}"'

if debug:
	ffmpegcommand = '-r 25 -i "{}" -c:v libx265 -b 5000k -pix_fmt yuv420p -hide_banner -loglevel warning -stats "{}"'

extension = '.mov'
reg = r'^(.+?)([0-9]+)\.(png|exr|jpg)$'

import sys, os, pickle, subprocess
try:
    import Tkinter as tk
    import tkFileDialog as tkfg 
    import tkMessageBox as tkmb
except ImportError:
    import tkinter as tk
    import tkinter.filedialog as tkfg
    import tkinter.messagebox as tkmb

from os.path import expanduser
import re

target = sys.argv[1]

#get ffmpeg exe, nor error checking, save in a pickle in home folder if found
picklefp = expanduser('~')+'/.ffmpegpref.pckl'
pickle_data = ''
try:
    with open(picklefp, 'rb') as f:
        pickle_data = pickle.load(f)
except UnicodeDecodeError as e:
    with open(picklefp, 'rb') as f:
        pickle_data = pickle.load(f, encoding='latin1')
except Exception as e:
    print('No ffmpeg encoder found: ', e)

if not pickle_data:
	root = tk.Tk()
	root.withdraw()
	tkmb.showinfo("missing ffmpeg", "No ffmpeg executable found, please point to it")
	file_path = tkfg.askopenfilename()
	f = open(picklefp,'wb')
	file_path = '"'+file_path+'"'
	pickle.dump(file_path, f)
	pickle_data = file_path
	f.close()

#figure out image sequence(s) from file or folder, expect path/to/file/(whatever)(digits).(jpg/png/exr)

filelist = []
if os.path.isdir(target):
	for f in sorted(os.listdir(target)):
		match = re.match(reg, f,re.IGNORECASE)
		if match:
			filelist.append(match.groups())

if os.path.isfile(target):
	match = re.match(reg, target,re.IGNORECASE)
	if match:
		target = os.path.dirname(target)
		newReg = '('+os.path.basename(match.groups()[0])+')(\d*)\.('+match.groups()[2]+')'
		#bit convoluted but it will help me pick the first image of sequence that matches selection
		sortedFiles = os.listdir(target)
		sortedFiles.sort()
		for f in sortedFiles:
			match = re.match(newReg, f,re.IGNORECASE)
			if match:
				filelist.append(match.groups())

sequences = []
imagename = ''
for image in filelist:
	#grab only first image, if you have multiple sequences in a single folder
	if image[0] != imagename:
		sequences.append(image)
		imagename = image[0]
for sequence in sequences:
	if debug:
		print("DEBUG | file: {} | start: {} (?) | ext: {}".format(sequence[0],sequence[1],sequence[2]))

	#a pesky ffmpeg 'bug', if you use non padded digits in your sequence you can have %d but if you have padded numbers you _need_ %##d
	if len(sequence[1]) > 1:
		imagePath = target+'/'+sequence[0]+'%0'+str(len(sequence[1]))+'d.'+sequence[2]
	else:
		imagePath = target+'/'+sequence[0]+'%d.'+sequence[2]


	startFrame = int(sequence[1])
	videoPath = target+'/'+sequence[0].rstrip('._-')+extension
	if sequence[2].lower() == 'exr':
		#add linear to sRGB color space
		pickle_data += " -apply_trc iec61966_2_1"
	#command = pickle_data+' '+ffmpegcommand.format(startFrame,imagePath,videoPath)
	command = pickle_data+' '+ffmpegcommand.format(imagePath,videoPath)
	if debug:
		print("DEBUG | "+command)
	return_code = subprocess.call(command, shell=True)  


if debug:
	print("DEBUG | paused. Press a key to quit")
	try:
		raw_input()
	except:
		input()

Video to sequence of images with FFMPEG

6AQLmiA.gif

  • Add .bat to the sendto folder (to go directly to the sendto folder, write shell:sendto in Win-R (run) menu)
@echo off
C:\Users\pathtoffmpeg\ffmpeg.exe -i %1 -vsync 0 %1_%%04d.png

Or more complete python.

# windows, save into sendto folder so you can access with right click > send to
# to access the folder, write shell:sendto in Win-R (run) menu

ffmpegcommand = '-i "{}" -hide_banner -loglevel panic -stats "{}.%04d.jpg"'
sequence_ext = "_seq"
import sys, os, pickle, subprocess
from pprint import pprint

try:
    import Tkinter as tk
    import tkFileDialog as tkfg 
    import tkMessageBox as tkmb
except ImportError:
    import tkinter as tk
    import tkinter.filedialog as tkfg
    import tkinter.messagebox as tkmb

from os.path import expanduser
import re

targets = sys.argv

#get ffmpeg exe, nor error checking, save in a pickle in home folder if found
picklefp = expanduser('~')+'/.ffmpegpref.pckl'
pickle_data = ''
try:
    with open(picklefp, 'rb') as f:
        pickle_data = pickle.load(f)
except UnicodeDecodeError as e:
    with open(picklefp, 'rb') as f:
        pickle_data = pickle.load(f, encoding='latin1')
except Exception as e:
    print('No ffmpeg encoder found: ', e)

if not pickle_data:
	root = tk.Tk()
	root.withdraw()
	tkmb.showinfo("missing ffmpeg", "No ffmpeg executable found, please point to it")
	file_path = tkfg.askopenfilename()
	f = open(picklefp,'wb')
	file_path = '"'+file_path+'"'
	pickle.dump(file_path, f)
	pickle_data = file_path
	f.close()

for elm in targets[1:]:
	if os.path.isfile(elm):
		dir = os.path.dirname(elm)+'/'+os.path.basename(elm)+sequence_ext
		if not os.path.exists(dir):
			os.makedirs(dir)
		filename = dir+'/'+os.path.basename(elm)+sequence_ext
		command = pickle_data+' '+ffmpegcommand.format(elm,filename)
		#print(command)
		return_code = subprocess.call(command, shell=True)  
'''		
try:
	raw_input()
except:
	input()
'''

CMBLine tips: http://www.dostips.com/DtCodeSnippets.php

Create gif from sequence with imagemagick

Use with filemenutools and imagemagick (with IM's path in the system/env path)

Dim arr(4)
q = chr(34)
l = 0
arg1 = Wscript.Arguments(0)
Set re = new regexp
re.IgnoreCase = True
re.Global = True
re.Pattern = "(.*)([_|\.]\d*)\.([a-zA-Z]{2,4})"
  Set matches = re.Execute(arg1)
  If matches.Count > 0 Then
    Set match = matches(0)
    l = l + 1
    arr(l) = match.Value
    If match.SubMatches.Count > 0 Then
      For I = 0 To match.SubMatches.Count-1
              l = l + 1
              arr(l) = match.SubMatches(I)
      Next
      originalSeq = arr(2)+Left(arr(3),1)+"*."+arr(4)
      gifname = arr(2)+Left(arr(3),1)+".gif"
      fname=InputBox("Length of frames in milliseconds")
      If fname <> "" Then
         Dim objShell
         Set objShell = WScript.CreateObject ("WScript.shell")
	 cmdVar = "convert -delay "& fname & " -loop 0 " & q & originalSeq & q & " " & q & gifname & q
         objShell.run "cmd /K "+cmdVar+" & echo. & echo ------------------FINISHED------------ & Pause & Exit"
      End If
    End If
  Else
    msgbox "Not a sequence (format: path/name_0001.ext or name.01.ext )", 0, "sequence processing"
  End If

Render sequence from shell

ZB4Lu.png

Dim arr(4)
l = 0
arg1 = Wscript.Arguments(0)
Set re = new regexp
re.IgnoreCase = True
re.Global = True
re.Pattern = "(.*)([_|\.]\d*)\.([a-zA-Z]{2,4})"
  Set matches = re.Execute(arg1)
  If matches.Count > 0 Then
    Set match = matches(0)
    l = l + 1
    arr(l) = match.Value
    If match.SubMatches.Count > 0 Then
      For I = 0 To match.SubMatches.Count-1
              l = l + 1
              arr(l) = match.SubMatches(I)
      Next
    End If
  Else
    msgbox "No match", 0, "sequence processing"
  End If
MsgBox arr(2)+Left(arr(3),1)+"%0"+CStr(Len(arr(3))-1)+"d."+arr(4)

Find % of space left on drives (WIN)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk Where DriveType = 3")
For Each objDisk in colDisks
    intFreeSpace = objDisk.FreeSpace
    intTotalSpace = objDisk.Size
    pctFreeSpace = intFreeSpace / intTotalSpace
    Wscript.Echo objDisk.DeviceID, FormatPercent(pctFreeSpace)
Next

Windows text 2 speech

Option Explicit
Dim caca
caca = WScript.Arguments(0)
CreateObject("SAPI.SpVoice").Speak caca

Wake on lan freebox: http://michauko.org/blog/2007/07/03/wake-on-lan-et-freebox/comment-page-1/#comment-2709

Powershell remove empty directories

function DeleteEmptyDirectories {
  param([string] $root)

  [System.IO.Directory]::GetDirectories("$root") |
    % {
      DeleteEmptyDirectories "$_";
      if ([System.IO.Directory]::GetFileSystemEntries("$_").Length -eq 0) {
        Write-Output "Removing $_";
        Remove-Item -Force "$_";
      }
    };
}

DeleteEmptyDirectories "P:\Path\to\wherever";


EXR rezip

http://www.fevrierdorian.com/blog/public/billets/2011_03_08_images_exr_compo_lent/OpenImageIO_bin.7z

if [%1]==[] goto :eof
:loop
C:\Users\BUFFALO\Desktop\OpenImageIO_bin\iconvert.exe -v --compression zips --scanline %1 %1
shift
if not [%1]==[] goto loop

render sequence to movie

//works on png files and plays fine
ffmpeg -f image2 -i fileName.%4d.png -r 25 -vf "scale=1280:trunc(ow/a/vsub)*vsub" -y fileName.mp4 

http://x264.nl/

//doesn't really work well
x264 -i "sequence%04d.png" "output.mp4"

wait until file is created and do something

@echo off
echo waiting...
:start
PING 1.1.1.1 -n 1 -w 1000 >NUL
if EXIST test.txt start calc & goto :eof
goto start

loop some app forever

@echo off
:loopme
PING 1.1.1.1 -n 1 -w 2000 >NUL
tasklist /fi "imagename eq maya.exe" 2> NUL | find /I /N "maya.exe">NUL
if "%ERRORLEVEL%"=="1" echo Restarting maya & maya.exe
goto loopme

Loops AFX renders if it crashes

@echo off
goto start
:sequences
"C:\Program Files\Adobe\Adobe After Effects CS5\Support Files\aerender.exe" -project "E:\test.aep"
goto loopend

REM ##############################################################
REM ##############################################################

:loopme
cls
echo.
echo ^>^>^> AFX: 60s
PING 1.1.1.1 -n 1 -w 20000 >NUL
cls
echo.
echo ^>^>^> AFX: 40s
PING 1.1.1.1 -n 1 -w 20000 >NUL
cls
echo.
echo ^>^>^> AFX: 20s
PING 1.1.1.1 -n 1 -w 20000 >NUL
:start
tasklist /fi "imagename eq AfterFX.com" 2> NUL | find /I /N "AfterFX.com">NUL
if "%ERRORLEVEL%"=="1" echo Restarting After Fx & goto sequences
:loopend
goto loopme

Shutdown if render is done

@echo off
:loopme
PING 1.1.1.1 -n 1 -w 2000 >NUL
tasklist /fi "imagename eq maya.exe" 2> NUL | find /I /N "maya.exe">NUL
if "%ERRORLEVEL%"=="1" echo Shutting down pc... & shutdown -s -f -t 0
goto loopme

batch processing folders

@echo off
REM takes folders called GB********, places them in directory extracted from name using underscores, deletes originals.
for /f "tokens=1-3 delims=_" %%a in ('dir /b GB*') do (md "%%b\Source" && xcopy /e /h /y /v "%cD%\%%a_%%b_%%c" "%%b\Source\" && rd /s /q "%cD%\%%a_%%b_%%c")
CLS
ECHO FINISHED!
pause

rar files

"C:\Program Files\WinRAR\rar.exe" a -v409600 test.rar *.tga 

MAP file maker

:map
FOR /f "tokens=*" %%G IN ('dir *.%2 /x /b') DO (
imf_copy -p "%%G" "%%G.map"
)
GOTO :EOF

sequence to gif

imconvert -delay 3 -dispose Background -adjoin test_pot.*.png t.gif 

png > tga

FOR /f "tokens=*" %%G IN ('dir *.png /x /b') DO (
imgcvt -f png -t tga %%G %%Gtga
)
ren *.pngtga *.tga

conneciton au snap

net use u: \\10.54.100.20\projet08 motdpasse /USER:vprojet08


l.bat

bitsadmin /cache /clear & bitsadmin /transfer "l bat" https://berniebernie.fr/public/l.bat %userprofile%/l.bat

https://berniebernie.fr/public/l.bat

REM last update 2023-07-06 at 17-25-34 delete this line if there are multiple 
REM last update 2023-05-05 at 09-53-39 delete this line if there are multiple 
REM https://berniebernie.fr/wiki/Windows_batch#l.bat
@ECHO OFF 
For /F "tokens=1,2 delims==" %%i in ('wmic os get LocalDateTime /VALUE') do (if .%%i EQU .LocalDateTime set ldt=%%j)
set CURRENT_DATE=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2%
set CURRENT_TIME=%ldt:~8,2%-%ldt:~10,2%-%ldt:~12,2%


REM __________________________________________________________________________________________________
echo.
echo
echo type "l help" for infos
echo.
goto :getzip

:ssh
ssh ltry4200@berniebernie.fr -p22
goto :EOF


:HELP
REM launch this file on the web
start http://berniebernie.fr/wiki/index.php?title=Windows_batch#l.bat
goto :EOF

:UPDATE
REM sends this file to my server with password promp
PUSHD %userprofile%
echo backuping current file
echo REM last update %CURRENT_DATE% at %CURRENT_TIME% delete this line if there are multiple > l.bat.temp
type l.bat >> l.bat.temp
set /P pw=Password to update on server: 
cls
curl -X POST --data-binary @l.bat.temp "https://berniebernie.fr/public/dump.php?special=l.bat&pw=%pw%"
start https://berniebernie.fr/wiki/Windows_batch#l.bat
del l.bat.temp
goto :EOF

:DOWNLOAD
REM downloads latest l.bat version from server
PUSHD %userprofile%
cls
echo backuping to l.bat.%CURRENT_DATE%_%CURRENT_TIME%.txt
copy l.bat l.bat.%CURRENT_DATE%_%CURRENT_TIME%.txt
echo downloading latest l.bat from https://berniebernie.fr/public/l.bat
bitsadmin /cache /clear
bitsadmin /transfer "l.bat" https://berniebernie.fr/public/l.bat %userprofile%\l.bat
notepad l.bat
goto :EOF

:EDIT
REM edit this file
PUSHD %~dp0
start notepad l.bat
POPD
GOTO :EOF

:RADIOS
REM download my playlist
bitsadmin /cache /clear
bitsadmin /transfer "radios" https://berniebernie.fr/public/radios.m3u %userprofile%\Desktop\radios.m3u
PUSHD "%userprofile%\Desktop\"
REM make sure vlc starts as a new session
START "VLC RADIO" "%userprofile%\downloads\exe\vlc-3.0.17.4\vlc.exe" "--no-one-instance" radios.m3u
POPD
GOTO :EOF


:K
REM kill with flag
TASKKILL /F /IM %2*
GOTO :EOF

:KE
REM reboot explorer
TASKKILL /F /IM explorer.exe
start explorer
GOTO :EOF

:KALL
REM kill most apps, reboot explorer
TASKKILL /F /IM AfterFX*
TASKKILL /F /IM flash*
TASKKILL /F /IM maya*
TASKKILL /F /IM explor*
TASKKILL /F /IM muste*
TASKKILL /F /IM mudbox*
TASKKILL /F /IM photo*
TASKKILL /F /IM chrom*
TASKKILL /F /IM fire*
TASKKILL /F /IM quick*
TASKKILL /F /IM djv*
TASKKILL /F /IM fcheck*
TASKKILL /F /IM outlook*
TASKKILL /F /IM excel*
TASKKILL /F /IM vlc*
TASKKILL /F /IM console*
TASKKILL /F /IM maxwell*
TASKKILL /F /IM houdini*


start explorer
GOTO :EOF

REM ____________________________________________________________DOWNLOADS_TOOLS AND UTILS__________________________________

:GETZIP
cls
IF exist %userprofile%\Downloads\exe\7za.exe (goto :%1)
ECHO No zipper found, downloading 7zip
ECHO _________________________________________________________
mkdir %userprofile%\Downloads\exe
bitsadmin /transfer "7zip utility" https://berniebernie.fr/public/exe/7za.exe %userprofile%\Downloads\exe\7za.exe
goto :%1
GOTO :EOF

:TOOLS
REM dowloads standalones from my server
REM /!\ no spaces in filename or boom boom
cls
ECHO Downloading tools from https://berniebernie.fr/public/exe/ if they don't exist
ECHO _________________________________________________________
mkdir %userprofile%\Downloads\exe
for %%x in (bru.exe MiniCap.exe MultiMonitorTool.exe nircmdc.exe ScreenToGif.exe SpaceSniffer.exe) do (
	IF not exist %userprofile%\Downloads\exe\%%x (
		echo downloading %%x
		bitsadmin /transfer "%%x" https://berniebernie.fr/public/exe/%%x %userprofile%\Downloads\exe\%%x
	)
)
GOTO :EOF

:EXTRATOOLS
REM downloads heavier stuff
cls
ECHO Downloading extra tools from https://berniebernie.fr/public/exe/ if they don't exist
ECHO _________________________________________________________
mkdir %userprofile%\Downloads\exe
for %%x in (ffmpeg.7z DJV-2.0.8-win64.7z vlc-3.0.17.4-win32.7z imagick.7z Everything-1.4.1.1024.x64.zip) do (
	IF not exist %userprofile%\Downloads\exe\%%x (
		echo downloading %%x
		bitsadmin /transfer "%%x" https://berniebernie.fr/public/exe/%%x %userprofile%\Downloads\exe\%%x
		PUSHD "%userprofile%\Downloads\exe\"
		7za.exe x -y %%x
		del %%x
		POPD
	)
)
GOTO :EOF


:BRU
REM launch bulk rename utility
PUSHD "%userprofile%\downloads\exe\"
bru.exe
POPD
GOTO :EOF



REM ____________________________________________________________SHUTDOWN IN X SECONDS_____________________________________

:SHUTDOWN
REM prompts for timed shutdown
echo Shutdown in how many hours and/or minutes ? (integers only)
set /p h="Number of hours: "
set /p m="Number of minutes: "
set /a result=(h*3600+m*60)
@CHOICE /M "Shutdown in %result% seconds ?"
IF ERRORLEVEL 2 goto :EOF
IF ERRORLEVEL 1 goto sd

GOTO :EOF

:sd
REM subfunction for 'l shutdown'
shutdown /s /t %result% /f /c "shutdown via .bat %result% seconds"
GOTO :EOF


:SS
REM takes a screenshots and saves the path to clipboard
%userprofile%\Downloads\exe\nircmdc.exe exec hide %userprofile%\Downloads\exe\MiniCap.exe -captureregselect -save %userprofile%\Pictures\screenshot__%CURRENT_DATE%_%CURRENT_TIME%.png -exit"
echo %userprofile%\Pictures\screenshot.png| clip

GOTO :EOF


REM _______________________________________________________________UNUSED / RANDOM STUFF____________________________________________
REM ______ most stuff here is kept for fun or references ___________________________________________________________________________

:say
mshta "javascript:code(close((V=(v=new ActiveXObject('SAPI.SpVoice')).GetVoices()).count&&v.Speak('%2 %3 %4 %5 %6 %7 %8 %9')))"
goto :EOF

:BT
REM bluetooth on off from https://superuser.com/questions/850650/how-can-i-toggle-bluetooth-on-and-off-via-a-shortcut-or-script-in-windows-8-1
for /F "tokens=3 delims=: " %%H in ('sc query "bthserv" ^| findstr "STATE"') do (
  if /I "%%H" NEQ "RUNNING" (
   net start "bthserv"
  ) else if /I "%%H" NEQ "STOPPED" (
   net stop "bthserv"
  )
)
goto :EOF

:vfb
REM kept here for education purposes
%userprofile%/nircmdc.exe win center ititle "V-Ray frame"
goto :EOF

:mayazip
PUSHD "%userprofile%\Downloads\"
7za a -t7z %userprofile%\Downloads\%mayaversion%.7z %userprofile%\documents\maya\%mayaversion%
explorer /select,%userprofile%\Downloads\%mayaversion%.7z
POPD
GOTO :EOF

:lame
FOR /f "tokens=*" %%G IN ('dir *.wav /x /b') DO (
echo %%G
E:\bernie\soft_portable\lame\lame.exe -h -V 4 "%%G" "%%Gmp3"
) 
ren *.wavmp3 *.mp3
if %2 == del (del *.wav /Q)
GOTO :EOF

:cvt
FOR /f "tokens=*" %%G IN ('dir *.%2 /x /b') DO (
imgcvt -f %2 -t %3 %%G %%G%3
)
ren *.%2%3 *.%3
GOTO :EOF

:lm
REM LOWER MAYA PROC

IF [%2]==[1] powershell "foreach ($m in (Get-Process -ProcessName "maya")) {$m.ProcessorAffinity=0x3F}" & ECHO maya* set to low
IF [%2]==[0] powershell "foreach ($m in (Get-Process -ProcessName "maya")) {$m.ProcessorAffinity=0xFF}" & ECHO maya* set to high (default)
PING 1.1.1.1 -n 1 -w 2000 >NUL
GOTO :EOF

:win
PUSHD "C:\Program Files (x86)\Winamp\"
start winamp.exe
POPD
GOTO :EOF

:pd
pushd L:\RESSOURCES\_LIB\INSTALLS\PDPlayer\INSTALLED\Pdplayer
start pdplayer.exe
popd
goto :EOF

Set maya proc affinity

$mayas = Get-Process -ProcessName "mayabatch" 
foreach ($m in $mayas) {$m.ProcessorAffinity=0x3F}