cscript.exe doesn't read unicode script (UTF-8) - unicode

simply save the following in notepad using UTF-8
msgbox "你好"
double click or run it from command line
D:\>cscript.exe /u test-unicode.vbs
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
D:\test-unicode.vbs(1, 1) Microsoft VBScript compilation error: Invalid characte
r
is there any way to run the unicode script in Windows Script Host?

cscript.exe can run scripts saved using [Unicode] (seems UTF-16).

Related

sqlplus run in script gives error :Enter password: ERROR: ORA-12560: TNS:protocol adapter error Enter user-name:"

I'm able to run sqlplus from the vscode powershell command line, but not in the script. In the command line it connects and returns results.
This is what the command looks like (at command line, which works fine).
echo exit | sqlplus user/pw#RRRPRD.company.net:1521/RRRPRDC '#C:\Users\me\Documents\2021\temp endToEnd\short.sql'
It says this on the screen and all looks good:
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
and it shows query results....
Then
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
I'm using VSCode now to run and work on the script.
This is the script:
...
$quote = '"'
$info = $("{0}/{1}#{2}:{3}/{4} ``#{5}{6}{5}" -f $username, $password,
$hostIp, $port, $service,
$quote, $sqlPath,$quote)
$result = ""
Write-Host "info: $info"
$result = sqlplus '$info'
Write-Host "result: $result"
But it's showing an error when I print result:
info: user/pw#RRRPRD.company.net:1521/RRRPRDC `#"C:\Users\me\Documents\2021\temp endToEnd\short.sql"
result: SQL*Plus: Release 12.2.0.1.0 Production on Tue Jan 11 11:00:19 2022 Copyright (c) 1982, 2016, Oracle. All rights reserved. Enter password: ERROR: ORA-12560: TNS:protocol adapter error Enter user-name:
The query it's running now is
select * from tablename; quit;
which runs fine in Oracle sql developer and command line. This has a few columns and a few rows.
I'm not clear on why it's not running in vscode/debug mode, but it runs the command at the command line. I've been fooling around with the backticks and it doesn't seem to make a difference for the error message running from vscode debugger. I tried just copying the command to a string to run in the script, but it's tough to get the formatting right so the string terminates without error.
Any ideas why it won't run in the powershell script, but runs in the command line, and what to do to fix it? I don't see anything online to fix this issue.
Update:
I'm seeing this [oracle home client][1], which seems similar, but isn't powershell. I'm not sure what I need to do for the fix they recommend.
Update: I did this at the command line and in the script:
(get-command sqlplus.exe).Path
and both print
C:\app\client\me\product\12.2.0\client_1\sqlplus.exe
Update2:
I’m told sqlplus location is different than oracle home client or the driver location used. I’m not sure about how to check/fix this.
echo $Env:Path at the vscode powershell prompt:
C:\Program Files (x86)\IBM\RationalSDLC\common;C:\Program Files (x86)\IBM\RationalSDLC\common;C:\app\client\me\product\12.2.0\client_1;C:\app\client\me\product\12.2.0\client_1\bin;C:\app\mcleary\product\12.2.0\client_1;C:\app\mcleary\product\12.2.0\client_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\PowerShell\7;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn;C:\Program Files\Azure Data Studio\bin;C:\Program Files (x86)\Progress\DataDirect\Connect_for_ODBC_71\Drivers;C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin;C:\Program Files (x86)\IBM\gsk8\lib;C:\Program Files (x86)\IBM\gsk8\bin;C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin;C:\Program Files (x86)\IBM\gsk8\lib;C:\Program Files (x86)\IBM\gsk8\bin;C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\RemoteClient\cteapis;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Users\me\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Azure Data Studio\bin;C:\Program Files\instantclient-basic-windows.x64-21.3.0.0.0;C:\Users\me.dotnet\tools;C:\Users\me\AppData\Local\Programs\Microsoft VS Code\bin
echo $Env:Path running the script through vscode :
C:\Program Files (x86)\IBM\RationalSDLC\common;C:\Program Files (x86)\IBM\RationalSDLC\common;C:\app\client\me\product\12.2.0\client_1;C:\app\client\me\product\12.2.0\client_1\bin;C:\app\mcleary\product\12.2.0\client_1;C:\app\mcleary\product\12.2.0\client_1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\PowerShell\7;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn;C:\Program Files\Azure Data Studio\bin;C:\Program Files (x86)\Progress\DataDirect\Connect_for_ODBC_71\Drivers;C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin;C:\Program Files (x86)\IBM\gsk8\lib;C:\Program Files (x86)\IBM\gsk8\bin;C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\bin;C:\Program Files (x86)\IBM\gsk8\lib;C:\Program Files (x86)\IBM\gsk8\bin;C:\Program Files (x86)\IBM\RationalSDLC\ClearCase\RemoteClient\cteapis;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Users\me\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Azure Data Studio\bin;C:\Program Files\instantclient-basic-windows.x64-21.3.0.0.0;C:\Users\me.dotnet\tools;C:\Users\me\AppData\Local\Programs\Microsoft VS Code\bin
[1]: https://gaurangpatel.net/tns-protocol-adapter-error-in-oracle

Access non-path WSLENV variable from WSL environment

I'm new to WSL as a development environment, and I'm trying to set some environment variable to begin working on an open source project. In this case, a domain and secret key. I've followed the steps mentioned here https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/ and here https://medium.com/#kevinv92/how-to-use-wslenv-to-share-environment-variables-between-windows-and-wsl-c06099d5b901 and this is output:
Microsoft Windows [Version 10.0.19041.388]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Users\kyles>wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Running 2
C:\Users\kyles>echo %WSLENV%
MVC_FIREBASE_API_KEY/p:MVC_FIREBASE_DOMAIN/p
C:\Users\kyles>echo %MVC_FIREBASE_DOMAIN%
minimum-viable-ceremonies-dev
C:\Users\kyles>wsl
kylesnowschwartz#DESKTOP-VN55S9F:/mnt/c/Users/kyles$ echo $WSLENV
MVC_FIREBASE_API_KEY/p:MVC_FIREBASE_DOMAIN/p
kylesnowschwartz#DESKTOP-VN55S9F:/mnt/c/Users/kyles$ echo $MVC_FIREBASE_DOMAIN
Nothing is output when for the environment variable, as I am expecting. I would appreciate any help in understanding what I don't understand!
The Microsoft blog entry is a bit confusing. Fortunately your problem is quite simple: You are using path translation option /p but your environment variable is not a path!
Passing environment variable from Windows to WSL, use /u option:
Microsoft Windows [Version 10.0.19044.1706]
(c) Microsoft Corporation. All rights reserved.
C:\Users\arttu>set MVC_FIREBASE_DOMAIN=minimum-viable-ceremonies-dev
C:\Users\arttu>set WSLENV=%WSLENV%:MVC_FIREBASE_DOMAIN/u
C:\Users\arttu>wsl
$ echo $MVC_FIREBASE_DOMAIN
minimum-viable-ceremonies-dev

Deploy and run Offscrub VBS Scripts from Intune silently

We would like to run the Office Removal VBS scripts on our group of Intune managed Windows 10 machines, aiming to remove all 32bit pre-installed Office products.
So far I've attempted to package all VBS scripts and accompanying Powershell script found on Github into an exe using IExpress.
Local execution of the exe produces unexpected results, I believe the controlling ps1 script is not being run correctly, or at all for that matter.
Here is the SED file for IExpress:
[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=0
HideExtractAnimation=0
UseLongFileName=0
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=
DisplayLicense=
FinishMessage=End of Script
TargetName=C:\PowerShellScripts\Remove Office 32bit Installs.EXE
FriendlyName=Remove Office 32bit Installs
AppLaunched=PowerShell.exe -noprofile -Sta -executionpolicy bypass -File Remove-PreviousOfficeInstalls.ps1
PostInstallCmd=<None>
AdminQuietInstCmd=
UserQuietInstCmd=
FILE0="OffScrub_O15msi.vbs"
FILE1="OffScrub_O16msi.vbs"
FILE2="OffScrub03.vbs"
FILE3="OffScrub07.vbs"
FILE4="OffScrub10.vbs"
FILE5="OffScrubc2r.vbs"
FILE6="Remove-PreviousOfficeInstalls.ps1"
[SourceFiles]
SourceFiles0=C:\PowerShellScripts\
[SourceFiles0]
%FILE0%=
%FILE1%=
%FILE2%=
%FILE3%=
%FILE4%=
%FILE5%=
%FILE6%=
Any assistance would be greatly appreciated.

How to force `dotnet` CLI to return non zero exit code?

I run dotnet from powershell script, and when I specify some unknown switch powershell does not detect any error. And output goes to stdout whereas I'd expect it to be stderr.
Is it a setting on dotnet or powershell side? I need script to fail in case of errors.
dotnet pack -dsfsdf Microsoft (R) Build Engine version
15.8.166+gd4e8d81a88 for .NET Core Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1001: Unknown switch. Switch: -dsfsdf
For switch syntax, type "MSBuild /help"
Indeed dotnet-pack writes errors to stdout, however it sets exit code to 1 in case of unknown parameter. You can check it with following code:
dotnet pack -asd
echo $LASTEXITCODE

Windows Shell. Restoring Orig Files

After a quick google search I found this link: Mercurial: simple way to revert .orig files?, with the following line of code in the comment:
for /f %i in ('dir /s /b *.orig') do #copy %i %~dpni
In powershell, I tried running it, but I got the following error: Missing opening ( after kyeword for.
Is powershell not the correct way to run this code or is the syntax incorrect?
I am trying to revert my orig files back to their original version (get rid of the .orig extension). I am using windows so BASH is not an easy option.
The comment that snippet came from suggests that the environment you can run that line in is the "Windows command prompt with Command Extensions."
You can create that environment like so: cmd /e:on. It didn't seem like using powershell was the intention, but you could type cmd /e:on into the powershell console and get that environment.
PS C:\> cmd /e:on
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\> Command Prompt Input is Valid Here
You received that error because that syntax is incorrect for powershell -- for statements expect parameters in parenthesis. It should work once you're in the appropriate shell, though.