Skip to main content
17-Peridot
September 28, 2016
Solved

Windows 10 and Creo Script Issues

  • September 28, 2016
  • 2 replies
  • 4350 views

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?


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
Best answer by jwagh

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

2 replies

jwagh17-PeridotAuthor
17-Peridot
October 11, 2016

Anyone? I would love to get some help on this.

jwagh17-PeridotAuthorAnswer
17-Peridot
October 20, 2016

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

21-Topaz II
October 21, 2016

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.

jwagh17-PeridotAuthor
17-Peridot
October 21, 2016

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.