cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Windows 10 and Creo Script Issues

jwagh
17-Peridot

Windows 10 and Creo Script Issues

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.
ACCEPTED SOLUTION

Accepted Solutions
jwagh
17-Peridot
(To: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

View solution in original post

4 REPLIES 4
jwagh
17-Peridot
(To:jwagh)

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

jwagh
17-Peridot
(To: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

dgschaefer
21-Topaz II
(To:jwagh)

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.

--
Doug Schaefer | Experienced Mechanical Design Engineer
LinkedIn
jwagh
17-Peridot
(To:dgschaefer)

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.

Announcements
NEW Creo+ Topics: PTC Control Center and Creo+ Portal


Top Tags