Error in Shell - file & folder related

itspeteritspeter Member Posts: 105
Hi,

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

Answers

  • wakestarwakestar Member Posts: 207
    try this:

    SHELL('c:\windows\SYSTEM32\REGSVR32.exe',' /S' + '"' + dllfilename + '"')
  • itspeteritspeter Member Posts: 105
    Thanks, it works fine.

    Have any idea for the create folder? :wink:
    Regards,
    Peter Ng
  • wakestarwakestar Member Posts: 207
    Sure :)
    SHELL('c:\windows\system32\cmd.exe','/C mkdir C:\Test');
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    :-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 :D
  • itspeteritspeter Member Posts: 105
    Old but still kickin. It works.

    Thanks.
    Regards,
    Peter Ng
  • janpieterjanpieter Member Posts: 298
    Uch .. oh no! A hard coded windows path ... !!

    Bad programming :mrgreen:

    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?
  • klavinklavin Member Posts: 117
    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."
  • janpieterjanpieter Member Posts: 298
    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?
  • klavinklavin Member Posts: 117
    Glad to hear it helped someone!

    -Lavin
    -Lavin
    "Profanity is the one language all programmers know best."
Sign In or Register to comment.