简体   繁体   中英

.bat convert to .exe not running

I have a visual I would like my users to remote into, open the browser, sign in and display the page, then log out of the remote session without the main screen being locked. I created a batch file to bring the window back up, but this then requires the use to minimize the requested display and defeats the purpose, so I want it to be a .exe that can be clicked from the task bar. When I convert my batch (which runs as expected) the .exe does nothing but sit there.

code:

set "params=%*"
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || (  echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B )

IF EXIST "%PROGRAMFILES(X86)%" (set bit=x64) ELSE (set bit=x86)

if %bit%==x64 (
    echo 64 bit operating system detected
)

if %bit%==x86 (
    echo 32 bit operating system detected
)

for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
  %windir%\System32\tscon.exe %%s /dest:console
)

timeout /t 2 >null

exit

Simply changing the .bat extension into .exe is not the right approach. I'd advise you to create an application (using Visual Studio or PyCharm, eg), which launches your batchfile and add this to the taskbar. Obviously you might also create a new application from scratch, doing exactly what your batchfile does.

I've tried adding the batchfile and a shortcut to the batchfile to the shortcut, but as you mentioned correctly, only *.exe files seem to be allowed on the taskbar.

I utilized a software to convert the batch file over after cutting out a lot of code. My code ended up being. I was then able to take the new .exe and pin it to taskbar and run it as desired. The .exe had to be run as admin.

for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)

timeout /t 2 >null

exit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM