Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 批处理脚本中的UTF-8_Batch File_Cmd - Fatal编程技术网

Batch file 批处理脚本中的UTF-8

Batch file 批处理脚本中的UTF-8,batch-file,cmd,Batch File,Cmd,获取脚本,该脚本在创建或修改某些内容时发送电子邮件通知。有一个小问题,脚本无法识别这些字母:ĄĘĖĮŲŪąęėšū 已尝试:chcp 65001 @echo off setlocal EnableDelayedExpansion set "emailUserName=foo@bar.com" set "emailPassword=lol" set "target=foo@bar.com" set "subject=ĄČĘĖĮŠ

获取脚本,该脚本在创建或修改某些内容时发送电子邮件通知。有一个小问题,脚本无法识别这些字母:ĄĘĖĮŲŪąęėšū

已尝试:
chcp 65001

@echo off
setlocal EnableDelayedExpansion
set "emailUserName=foo@bar.com"
set "emailPassword=lol"
set "target=foo@bar.com"
set "subject=ĄČĘĖĮŠŲŪ("
FOR %%G IN (*) DO attrib -A "%%G"
:loop
set "body="
FOR %%G IN (*) DO (
attrib "%%G" | findstr /B /L A 1>nul
if !errorlevel! equ 0 (
    echo "%%G"
    set "body=!body!^<br ^/^>%%G"
    attrib -A "%%G"
    )
) 2>nul
if not "%body%"=="" echo sending email
if not "%body%"=="" set "body=Buvo ikelta nuotrauka:!body!"
if not "%body%"=="" powershell.exe -command "Send-MailMessage -From 
'!emailUserName!' -to '!target!' -Subject '!subject!' -Body '!body!' - 
BodyAsHtml -SmtpServer 'smtp.gmail.com' -port '587' -UseSsl -Credential (New- 
Object -TypeName System.Management.Automation.PSCredential -ArgumentList 
('!emailUserName!', (ConvertTo-SecureString -String '!emailPassword!' - 
AsPlainText -Force)))"
goto :loop
@echo关闭
setlocal EnableDelayedExpansion
设置“电子邮件用户名”=foo@bar.com"
设置“emailPassword=lol”
设定“目标”=foo@bar.com"
设置“主题=
对于(*)中的%%G,执行属性-A“%%G”
:循环
设置“body=”
对于%%G IN(*)DO(
属性“%%G”|查找顺序/B/L A 1>nul
如果!错误级别!等于0(
回声“%%G”
设置“body=!body!^%%G”
属性-A“%%G”
)
)2>nul
如果不是“%body%”,则返回发送电子邮件
如果不是“%body%”==“set”body=Buvo ikelta nuotrauka:!body!”
如果不是“%body%”==“powershell.exe-命令”发送邮件消息-从
“!emailUserName!”-至“!target!”-主题”!主题!'-正文”!正文!'-
BodyAsHtml-SmtpServer'smtp.gmail.com'-端口'587'-使用SSL-凭据(新-
对象-TypeName System.Management.Automation.PSCredential-ArgumentList
(“!emailUserName!”,(转换为SecureString-String”!emailPassword!'-
AsPlainText-Force))”
转到:循环

CMD是ANSI,而不是unicode

因此,支持的字符取决于计算机中配置的代码页

您尝试使用的字符在脚本中是硬编码的,您只需将脚本保存在ansi中,或者它来自脚本的输入,然后您最好使用vbs或powershell之类的其他工具