Persmissions issue when running Shell command
Riddick
Member Posts: 4
I created a CU to run HotCopy.exe and attached the CU to the Job Queue scheduler. The scheduler kicks in and runs the CU, as expected. But for some reason I see an error message in the Application Events log:
The following information is part of the event: For security reasons, you are not allowed to run the following
executable in the SHELL function when it is passed as a variable:
Executable: echo %USERNAME% >> c:\BACKUP\testrun.log
Parameter:
No matter which file I try to run via SHELL, same message pops up. I am logged in as SUPER user with all the privileges on the DB. Any idea why this error message pops up?
TIA.
The following information is part of the event: For security reasons, you are not allowed to run the following
executable in the SHELL function when it is passed as a variable:
Executable: echo %USERNAME% >> c:\BACKUP\testrun.log
Parameter:
No matter which file I try to run via SHELL, same message pops up. I am logged in as SUPER user with all the privileges on the DB. Any idea why this error message pops up?
TIA.
0
Comments
-
Hi,
have a look at the C/SIDE reference online help for shell:BEGIN // The following is NOT trusted and will give a warning: ExecName := 'C:\windows\notepad.exe'; param := 'C:\MyFile.txt'; ret := SHELL(ExecName, param); // The following IS trusted and will not give a warning: param := 'C:\MyFile.txt'; ret := SHELL(TEXT000, param); //The following is not possible - will only give an error //message during runtime. This is also if it's a TextConst: ExecName := 'C:\windows\notepad.exe C:\MyFile.txt'; ret := SHELL(ExecName); END;
So you should set the shell path to the executable as text constant and only make the parameter a normal string.
ret := SHELL(TEXT000, param);
(But you could also use '%1' in the textconstant and then use STRSUBSTNO (String) and you won't get an error too)Karsten Frank
MCP - Dynamics NAV Developer0 -
Maybe it is easier to create a cmd-file with the command in it and schedule it on the server through Windows scheduling.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Seems that Shell will only execute properly when a text CONSTANT is used. What's interesting is that I can say Shell('cmd.exe') and it will run just fine. But as soon as I pass it a full path name with a command file, Shell thinks there is a security breach and won't run unless it sees a text constant (with that same path and file name). Strange, but nonetheless true, seems it will only "trust" built in commands and apps.
Shell(TEXT001) works fine.0 -
When using SHELL with a command like "echo %USERNAME% >> c:\BACKUP\testrun.log" you will always have the security issue. This is due to %USERNAME% and therefore Navision assumes that you are running a "new" program each time.
If for instance it always was "echo SchedulerUSER >> c:\Backup\testrun.log", which your text constant properly is, you will not have this issue. Because it is always the same command - only the first time you have to acknowledge the security issue.
If you would like to use %USERNAME%, then instead of SHELL you can use WshShell (it is a part of the automation "Windows Script Host Object Model"). When using WshShell you will not get any security warnings.
You can ready more about it here: http://techblog.byllemos.com/2008/04/execution-of-batch-jobs-and-other-programs-from-navision/0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 333 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions