I have the following batch file which basically copies another bat file from the shared folder, selects this bat file and sends ENTER key with sendkeys option.
It all works fine on Windows 7, however, as soon as I try to use the same feature on Windows 10 it won't work properly.
It does copy file in a specific folder, it does open this folder with the selected file but it won't start file itself. It is important in my case to start the file with sendkeys feature.
I assume that the problem is caused by not keeping the opened folder in focus, sendkeys does send ENTER button, but since the selected folder is not in the windows focus batch file is not started automatically.
Is there any possible way to focus windows on the opened folder?
@if (@CodeSection == @Batch) @then
@echo off
set SendKeys=CScript //nologo //E:JScript "%~F0"
xcopy "\\fs\FIle Share\SA Support\ZverTools\Win10UninstallUnnecessaryApps.bat" "%USERPROFILE%" /y
PING localhost -n 2 >NUL
set targetfilepath=%USERPROFILE%\Win10UninstallUnnecessaryApps.bat
%SystemRoot%\explorer.exe /select, "%TARGETFILEPATH%"
PING localhost -n 1 >NUL
%SendKeys% "{ENTER}"
goto :EOF
@end
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));