IDK what I done but this is Not working Anymore in my Cmd - batch-file

Hey Guys I tweaked my Windows and when I try to use some text like in the example it puts not that out what it should be anyone know a fix for it ?
example :
#echo off
echo.
echo [90m██╗ ██████╗ ██████╗ ██╗███╗ ██╗
echo [90m██║ ██╔═══██╗██╔════╝ ██║████╗ ██║
echo [90m██║ ██║ ██║██║ ███╗██║██╔██╗ ██║
echo [90m██║ ██║ ██║██║ ██║██║██║╚██╗██║
echo [90m███████╗╚██████╔╝╚██████╔╝██║██║ ╚████║
echo [90m╚══════╝ ╚═════╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝
pause
Idk what I should write here

Related

Having trouble with color code in batch file

I'm trying to only have ffmpeg progress to be colored, but for some reason when I terminate or go full-screen this monstrosity occurs:
Issue
#echo off
#echo off
title Stream Recorder
cls
:start
set message=Stream Recorder
echo %message%
echo(
echo [32m1. Chrome [0m
echo [34m2. Edge [0m
echo [33m3. Firefox [0m
echo [31m4. Opera [0m
echo [1;31m5. Vivaldi [0m
:choice
set choice=
set /p "choice=* Pick your browser (between 1-5): "
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto chrome
echo "%choice%" is not valid, try again.
ECHO.
goto choice
:chrome
:url
echo(
set /p "address=* M3U8 Url: "
For /F %%G In ('%__AppDir__%curl.exe -s -o NUL "%address%" -w "%%{http_code}\n"') Do Set "response=%%G"
echo %response%
IF %response% == 200 (
ECHO [32mURL check was successful.[m &goto :username
) ELSE (
ECHO [31mURL is not valid, try again.[m &goto :url
)
:username
set /p "filename=* Streamer Name: "
echo(
set message=* Recording:
echo [0m%message%[42;1m
ffmpeg -v warning -hide_banner -stats -user_agent "" -i "%address%" -c copy "%~dp0/%filename%_%DATE:~7,2%-%DATE:~4,2%-%DATE:~-4%_%time:~-11,2%-%time:~-8,2%-%time:~-5,2%.mp4"
pause
Also, would be helpful if my code needs some cleaning up.
That last echo is the problem:
echo Escape[0m%message%Escape[42;1m
The first Escape chunk turns off color and bold, while the second turns color and bold on.
To fix the problem, you need (at least)
echo Escape[0m
before the pause. But that may not be enough, because ffmpeg is printing to the terminal (presumably) without modifying colors. If it happens to clear the current line or to the end of the display, most terminals (supporting back color erase) will fill the cleared area with the current color.
Perhaps you don't want ffmpeg to have that opportunity.

vbscript opens mp4 in wmplayer, but only audio plays

I'm trying to simply open a video in full screen using a batch file, I realised this wasn't possible so I included code to make it write to vbscript instead and then later on execute the vbscript code.
I'm running windows 10, and I have another script running an mp3 file that works fine.
This is what my batch file is writing to the vbscript
set "file2=res\FORTNITESKINS.mp4"
( echo Set wmp = CreateObject("WMPlayer.OCX"^)
echo Video.URL = "%file2%"
echo Video.Controls.play
echo do while Video.currentmedia.duration = 0
echo wscript.sleep 100
echo loop
echo wscript.sleep (int(Video.currentmedia.duration^)+1^)*1000
echo set WshShell = WScript.CreateObject("WScript.Shell"^)
echo WScript.Sleep 1000
echo WshShell.SendKeys "%{ENTER}") >video.vbs
This is how I execute the vbscript
start video.vbs
The video does not open, only the audio plays, and wmplayer doesn't even open minimized, nor can I find it in task manager.
I have also tried this,
set "file2=res\FORTNITESKINS.mp4"
( echo Set Video = CreateObject("WMPlayer.OCX"^)
echo Video.openPlayer("%file2%"^)
echo set WshShell = WScript.CreateObject("WScript.Shell"^)
echo WScript.Sleep 1000
echo WshShell.SendKeys "%{ENTER}") >video.vbs
but it gives the error:
Line: 2
Char: 1
Error: 0xC00D1329
Code: C00D1329
Source: (null)
Why don't you use wmplayer directly with proper command-line-parameters ?
#Echo off
set "file2=res\FORTNITESKINS.mp4"
set wmplayer="%ProgramFiles(x86)%\Windows Media Player\wmplayer.exe" /prefetch:1
%wmplayer% "%file2%" /fullscreen
You can do it like this example :
#echo off
Mode 70,3 & color 0B
echo(
Set "Title=Playing videos with Windows Media Player"
Title %Title%
echo %Title%
Set "URL-FILE=http://1290922571.rsc.cdn77.org/movies/Superman-Unbound-2013-FRENCH.mp4/playlist.m3u8"
Start "%Title%" wmplayer /fullscreen "%URL-FILE%"
Timeout /T 2 /NoBreak>nul
EDIT :
#echo off
Mode 70,3 & color 0B
echo(
Set "Title=Playing videos with Windows Media Player"
Title %Title%
echo %Title%
Set vbs_video=%temp%\vbs_video.vbs
Set video=http://1290922571.rsc.cdn77.org/movies/Superman-Unbound-2013-FRENCH.mp4/playlist.m3u8
Call :Play %video%
Timeout /T 2 /NoBreak>nul & Exit
REM ***************************************
:Play <video>
(
echo Set Video = CreateObject("WMPlayer.OCX"^)
echo Video.openPlayer("%~1"^)
echo set WshShell = CreateObject("WScript.Shell"^)
echo WScript.Sleep 3000
echo WshShell.SendKeys "%%{ENTER}"
)>"%vbs_video%"
Start "video" "%vbs_video%"
exit /b
REM ***************************************
set "file2=F:\ull\path\to\res\FORTNITESKINS.mp4"
You must enter the full path to the file for the script to work. Including the drive letter and the path to the current folder.

Batch file - Multiple FTP upload with wildcard match

I need to upload via FTP some files (not all) from a folder to a remote server.
I coded the following which performs the wildcard match, but I think I am missing something to FTP the resulting files.
Remark: the problem is not to upload the folder (which is relatively simple), but to exclude some entries from the given folder and upload all other files.
I was successful in excluding those files and keep the rest, but I can't find the way to upload the latter.
In particular, mput cmd seems to not work with the input filename. Why ?
I want to focus on this question: how can I feed the FTP cmds to upload each resulting file from the above filtering ?
echo off
setlocal enabledelayedexpansion
FOR /R localfolder %%F IN (*.*) DO (
set fname=%%~nF
set ext=%%~xF
set filename=!fname!!ext!
set subfname=!fname:~0,4!
IF NOT "!subfname!" == "idat" (
echo ftp
echo open ftp.something.it
echo ftpuser
echo ftppass
echo lcd localfolder
echo cd remotefolder
echo binary
echo mput !filename!
echo disconnect
echo bye
)
)
pause
This is the solution, I was nearly close to it: just fill-in an external batch .bat file with ftp commands and then call this file at the end of each loop. Delete it and start again with the next entry on the list.
p.s.: for any further usage, beware of trimming any blank spaces before >> operator, as shown below.
#echo off
setlocal enabledelayedexpansion
FOR /R localfolder %%F IN (*.*) DO (
set fname=%%~nF
set ext=%%~xF
set filename=!fname!!ext!
set subfname=!fname:~0,4!
IF NOT "!subfname!" == "idat" (
echo open ftp.something.it>> ftp.cmds.bat
echo username>> ftp.cmds.bat
echo password>> ftp.cmds.bat
echo lcd localfolder>> ftp.cmds.bat
echo cd remotefolder>> ftp.cmds.bat
echo binary>> ftp.cmds.bat
echo mput !filename!>> ftp.cmds.bat
echo disconnect>> ftp.cmds.bat
echo bye>> ftp.cmds.bat
ftp -i -s:ftp.cmds.bat
del ftp.cmds.bat
)
)
Next script could help. Read List of FTP commands for the Microsoft command-line FTP client
#ECHO OFF
SETLOCAL EnableExtensions EnableDelayedExpansion
set "localfolder=D:\test\31441809\root" change
set "lcd-folder=%localfolder%"
set "excludeFile=nico" change to `idat`
set "ftpscript=%temp%\35574454ftp.dat" change
(
echo open ftp.something.it
echo user ftpuser
echo ftppass
echo binary
echo cd remotefolder
echo lcd %lcd-folder%
FOR /R %localfolder% %%F IN (*.*) DO (
set "fname=%%~nF"
set "ext=%%~xF"
set "filename=!fname!!ext!"
set "subfname=!fname:~0,4!"
IF /I NOT "!subfname!"=="%excludeFile%" (
if /I not "!lcd-folder!\"=="%%~dpF" (
rem change local directory only if necessary
set "lcd-folder=%%~dpF"
set "lcd-folder=!lcd-folder:~0,-1!" remove trailing backslash
echo lcd !lcd-folder!
)
echo put !filename!
)
)
echo disconnect
echo bye
)>"%ftpscript%"
type "%ftpscript%"
pause
ftp -i -n -s:"%ftpscript%"
Sample output:
d:\bat> D:\bat\SO\35574454.bat
open ftp.something.it
user ftpuser
ftppass
binary
cd remotefolder
lcd D:\test\31441809\root
put JohnDoe.txt
lcd D:\test\31441809\root\Ian-ionescu
put Ian-ionescuY.txt
lcd D:\test\31441809\root\John-doe
put John-doe.txt
put John-doeA.txt
lcd D:\test\31441809\root\Nicola-sheperd
put SheperdNicola.txt
lcd D:\test\31441809\root\Sara-smith
put Sara-smith.txt
put Sara-smithZ.txt
disconnect
bye
Press any key to continue . . .
ftp> open ftp.something.it
Connected to www.something.it.
220 FTP Server ready.
ftp> user ftpuser
331 Password required for ftpuser.
etc.etc.

Windows Server 2008 r2 dsadd usercreation does not work

i made a batchfile that is supposed to create users from a txt file but somehow it seems to skip the (for /f .........) dsadd part :( am i doing something wrong?
It's Fixed thx :D
this is the working code
#echo off
cls
echo Creating Accounts
echo -----------------
for /F "tokens=1-2" %%A in (Users.txt) do dsadd user cn=%%A,ou=OU-%%B,dc=school,dc=local -disabled no -pwd Welkom01 -memberof cn=%%B,ou=OU-%%B,dc=school,dc=local -hmdir \\DC01\%%A$\Data -hmdrv S: -profile \\DC01\%%A$\Profile -canchpwd yes -pwdneverexpires yes
echo -----------------
pause
{ANSWERED}
The right code is
#echo off
cls
echo Creating Accounts
echo -----------------
for /F "tokens=1-2" %%A in (Users.txt) do dsadd user cn=%%A,ou=OU-%%B,dc=school,dc=local -disabled no -pwd Welkom01 -memberof cn=%%B,ou=OU-%%B,dc=school,dc=local -hmdir \\DC01\%%A$\Data -hmdrv S: -profile \\DC01\%%A$\Profile -canchpwd yes -pwdneverexpires yes
echo -----------------
pause
the file got messed up becouse I made it with parts of other codes. :)

bat file Error "invalid verb switch" when using wmic

Hey guys i need some help i am a total noob to bat files i am getting this error "invalid verb switch" I dont understand why?
All i am wanting to do is rename the current user with %newusername%
I have looked on line and everything seams to be the same any thoughts?
#echo off
for /F "tokens=4 delims=.:" %%G in (
'ping -4 %COMPUTERNAME%^|find "Reply from"'
) do set "IP=%%G"
set "ipadd=%IP:~-3%"
set mydate=%date:~4,2%%date:~7,2%%date:~10,4%
set /p pathName=Employees Name:%=%
set /p store=Store prefix (ie: rfl, rac, rca, rdcjr):%=%
set /p location=location (ie: salesflrN1, partsNE2):%=%
echo.
echo.
echo ip address: %last3digits%
set newusername=%store%.%ipadd%-%pathName%
echo New User Name Will Be: %newusername%
echo.
echo ___________________________________________________________________________
echo ***************************************************************************
echo ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
echo.
echo By Pressing enter you will be performing the following actions....
echo.
echo 1. Updating The computers name to: *******
echo 2. Updating The computers User Name to: *******
echo 3. And You Will Be Forceing A System Reboot: *******
echo.
echo 3. Press "Enter" To Continew Or Alt+F4 To Exit
echo.
echo ___________________________________________________________________________
echo ***************************************************************************
echo ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
pause
wmic useraccount where name='%username%' rename %newusername%
pause
This ended up fixing my error:
wmic useraccount where name='%USERNAME%' call rename name='%newusername%'
net.exe user "%newusername%" /fullname:"%newusername%"
Looks like I was missing the call and name= option.

Resources