Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

This App cannot run on your PC message

This App cannot run on your PC message

I am trying to run a .cmd file but keep getting this pop message shown below

Any help ?

Thank you
 User generated image
Avatar of Noah
Noah
Flag of Singapore image

Hi there! :)

Firstly, you might want to try running running the file as an administrator. That might do the trick.
run-batch-file-explorer_win10.webp

Secondly, I noticed that Windows Server 2012 is tagged in this question. This could mean that you might need your admin to add the software for you since a normal user might not be allowed those permissions or changes.

Could you also attach the .cmd or .bat file you are trying to run?
Avatar of jskfan

ASKER

I am logged in with domain admin account to windows server 2012 , I also have run the file as Administrator. I get the same message.

the file content is as follows:

cscript.exe "C:\windows\system32\Printing_Admin_Scripts\en-US\prnport.vbs" -
a  -s Windows7 -r "printer1" -h hostname -o raw -n 9100

timeout 5

cscript C:\Windows\System32\Printing_Admin_Scripts\en-US\prnmngr.vbs -a  -p
"Myprinter" -m "HP 910" -r "printer1" -s Windows7

timeout 5

powershell.exe c:\printer.ps1

Open in new window


the printer.ps1 file content is :

$printer = Get-WmiObject -Class Win32_Printer -Filter "Name = 'Myprinter'" -ComputerName windows7
$printer.Direct= $true
$printer.Put()

Open in new window

Could you try with the following methods:
1.
Open Start.
Search for Windows PowerShell ISE, right-click the top result, and select the Run as administrator option.
Click on File.
Select the New option to create a new empty .ps1 file.
Write a new or paste the script you want to run

2.
Open Start.
Search for PowerShell, right-click the top-result and click the Run as administrator option.
Type the following command to allow scripts to run and press Enter:
Set-ExecutionPolicy RemoteSigned
Type A and press Enter (if applicable).
Type the following command to run the script and press Enter:
& "c:\printer.ps1"
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

David Johnson, CD

Brilliant!!!

It worked without any error.... Can you please explain the changes you made to the script ?

Thank you
other than the @echo statements which simply display program status to the screen using the -executionpolicy bypass allows all script to be run no matter what the execution policy in the registry is
Avatar of jskfan

ASKER

Thank you for your Help!!