Error in Shell - file & folder related
 
            
                
                    itspeter                
                
                    Member Posts: 105                
            
                        
            
                    Hi,
I need to register a DLL file in client.
In case you ask me why I need to do this. You can refer here
More Info: -
Navision 4.0
Windows Authentication
Thanks.
                I need to register a DLL file in client.
lint_Status:=SHELL('REGSVR32 /S ' + '"' + DLLFILENAME + '"')
--------------------------- Microsoft Business Solutions-Navision --------------------------- The file name "REGSVR32 /S C:\PROGRAM FILES\COMMON FILES\Navision\NTimer.dll" contains a character that may not be used. Please check the file name. You can find additional information on file names in the documentation for your operating system. --------------------------- OK ---------------------------Same error when I want to create a folder.
--------------------------- Microsoft Business Solutions-Navision --------------------------- The file name "MD C:\PROGRAM FILES\COMMON FILES\Navision" contains a character that may not be used. Please check the file name. You can find additional information on file names in the documentation for your operating system. --------------------------- OK ---------------------------But, both command above can run perfectly well in bat file.
In case you ask me why I need to do this. You can refer here
More Info: -
Navision 4.0
Windows Authentication
Thanks.
Regards,
Peter Ng
Peter Ng
0                
            Answers
- 
            try this:
 SHELL('c:\windows\SYSTEM32\REGSVR32.exe',' /S' + '"' + dllfilename + '"')0
- 
            Thanks, it works fine.
 Have any idea for the create folder? Regards, Regards,
 Peter Ng0
- 
            Sure 
 SHELL('c:\windows\system32\cmd.exe','/C mkdir C:\Test');0
- 
            :-s
 That is nice! Using (very) old ms-dos commands to make directories in Navision :shock:
 Well, if it works it's ok I guess 0 0
- 
            Old but still kickin. It works.
 Thanks.Regards,
 Peter Ng0
- 
            Uch .. oh no! A hard coded windows path ... !!
 Bad programming 
 Although thanks for the sollutions this code seems to work on networkpaths as well and the createfolder of the FileSystemObject does not.
 Although here is my improvement. Some people install windows on a different path or drive.FolderName := 'c:\mytestfolder\mytestsubfolder\'; SHELL(ENVIRON('windir') + '\system32\cmd.exe', '/C mkdir ' + FolderName);In a world without Borders or Fences, who needs Windows and Gates?0
- 
            FileSystemObject certainly can create network folders...
 This code may be sloppy, I wrote it when I first was learning NAV years ago but it works.
 '\\servername\folder\folder2\folder3\something.txt'
 It will make sure
 \\servername\folder\folder2\folder3\ is there, if not create the necc. folders, same with 'c:\test\test2\test.txt'CheckIfFolderExists(Filename : Text[1024]) IF NOT CREATE(FileSystemObject) THEN EXIT; IF STRPOS(Filename,'\') > 0 THEN BEGIN i := 1; ServerNameEnd := 0; ServerPath := FALSE; CheckedIfServerPath := FALSE; REPEAT i += 1; MakeFolder := FALSE; IF (COPYSTR(Filename,1,2) = '\\') AND NOT (CheckedIfServerPath) THEN BEGIN CheckedIfServerPath := TRUE; ServerPath := TRUE; s := 2; REPEAT s += 1; IF COPYSTR(Filename,s,1) = '\' THEN ServerNameEnd := s; UNTIL (s > STRLEN(Filename)) OR (ServerNameEnd <> 0); END; IF ServerPath THEN BEGIN IF (COPYSTR(Filename,i,1) = '\') AND (i > ServerNameEnd) THEN MakeFolder := TRUE; END ELSE BEGIN IF (COPYSTR(Filename,i,1) = '\') AND (i > 3) THEN BEGIN //make sure it isnt the root MakeFolder := TRUE; END; END; IF MakeFolder THEN IF NOT FileSystemObject.FolderExists(COPYSTR(Filename,1,i)) THEN FileSystemObject.CreateFolder(COPYSTR(Filename,1,i)); UNTIL i > STRLEN(Filename); END;-Lavin
 "Profanity is the one language all programmers know best."0
- 
            Thanks Klavin.
 Today i noticed the shell command had serious disadvantages and your code helped me out!.In a world without Borders or Fences, who needs Windows and Gates?0
- 
            Glad to hear it helped someone!
 -Lavin-Lavin
 "Profanity is the one language all programmers know best."0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 322 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



