Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Apparently, Windows 10 has gotten very strict concerning what they allow a batch file to do unless you are the admin on the computer. Even if you have admin rights, it won't work - you must be logged in as admin. From my limited research, apparently we need to create signed certificates in order to get these to work again. For example, the below code used to uninstall ProductView Express 9.1. It no longer is allowed in Windows 10 unless you are the admin.
wmic product where name="ProductView Express 9.1" call uninstall >nul 2>&1
.Anybody have experience with this? I'm going to have to deal with it sooner than later and want to at least be prepared.
What worked, what didn't work? How did you get around this?
Solved! Go to Solution.
Found a solution here: Create a Batch File that Runs as Admin Automatically | TechGainer
It does open another window almost instantly, but I think it will be fine for now. Code below:
:: BatchGotAdmin (Run as Admin code starts)
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:: BatchGotAdmin (Run as Admin code ends)
:: Your codes should start from the following line
Anyone? I would love to get some help on this.
Found a solution here: Create a Batch File that Runs as Admin Automatically | TechGainer
It does open another window almost instantly, but I think it will be fine for now. Code below:
:: BatchGotAdmin (Run as Admin code starts)
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
exit /B
:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
pushd "%CD%"
CD /D "%~dp0"
:: BatchGotAdmin (Run as Admin code ends)
:: Your codes should start from the following line
Does this run the succeeding code as if logged in as "Administrator' or as the current user with Admin privileges?
I've had issues when running a batch file as administrator because the administrator account doesn't have the same network drive letter mapping as the users.
For Windows 10, I believe the former. We've given the user "admin privileges" and many commands still did not work (like some wmic uninstall commands). This made it work.