Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: Error 30 from call to OS_GetComputerName

  1. #1

    Error 30 from call to OS_GetComputerName

    On one of my user's computers, they get the following error when they run my code:

    Main Script Name : C:UsersxxDownloadsFirmware_v270_WinEBBUpgraderGUI_v270.exe
    Error code 30
    Line number 26
    Token found OS_GETCOMPUTERNAME

    This occurs on the following line (line 26)
    Global ComputerName As String Value OS_GetComputerName

    This program has run fine on thousands of different computers. Any idea what "Error code 30" is and what could cause OS_GetComputerName to fail this way?

    Thanks much-
    *Brian

  2. #2

    Question

    Hi Brian,

    maybe knowing what system (real windows : which version ?, virtualization, wine...) is the program running on would be of some help.
    Also the computer name ( = expected name ?)

    Regards
    Last edited by DirectuX; 21-02-2021 at 23:34.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  3. #3
    Sure, I'll provide what I know.

    The computer system where the error is generated is Windows 10. I do know if it is up to date or not.

    I don't think it's being virtualized, although I can try to contact the user and ask.

    I don't know what the expected "Computer Name" is for their machine. What can I ask them to do to provide this information? Is there an easy way of reading out the "Computer Name" value that will normally be returned by the OS_GetComputerName call?

    *Brian

  4. #4
    Maybe this MS link can help you display the computer name, it's in the system panel.

    Quote Originally Posted by EmbeddedMan View Post
    Sure, I'll provide what I know.

    The computer system where the error is generated is Windows 10. I do know if it is up to date or not.

    I don't think it's being virtualized, although I can try to contact the user and ask.

    I don't know what the expected "Computer Name" is for their machine. What can I ask them to do to provide this information? Is there an easy way of reading out the "Computer Name" value that will normally be returned by the OS_GetComputerName call?

    *Brian
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Brian,

    can your user try this script on his PC, will it improve the situation?
    dword bufferSize = 1024
    dim buffer as asciiz * bufferSize
    
    
    DECLARE FUNCTION GetComputerName IMPORT "KERNEL32.DLL" ALIAS "GetComputerNameW" (BYREF lpBuffer AS ASCIIZ, BYREF nSize AS DWORD) AS LONG
                                        
    GetComputerName(buffer, bufferSize)
    
    
    msgbox 0, buffer
    

    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6
    Thanks - I'll build a new version of the app for them to try with that change and let you know how it goes. Thanks!!

    *Brian

  7. #7
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,529
    Rep Power
    170
    this for Error 30
    Quote Originally Posted by source:microsoft
    ERROR_READ_FAULT
    30 (0x1E)
    The system cannot read from the specified device.
    and this for the next time
    https://docs.microsoft.com/en-us/win...-codes--0-499-
    I think there are missing some Forum-sections as beta-testing and support

  8. #8
    Quote Originally Posted by ReneMiner View Post
    this for Error 30


    and this for the next time
    https://docs.microsoft.com/en-us/win...-codes--0-499-
    Fair enough, but what about the actual function call could return that error? The error itself doesn't give me any ideas on what I can ask my user to check in order to solve the problem.

    *Brian

  9. #9
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,529
    Rep Power
    170

    Run As Admin

    i would suspect the script usually is started by some link thats properties say to run it as administrator. the original link that you created once was moved accidentally and someone made a new link to replace the missing one but didn't know the "Run as administrator" has to be checked

    anyway, if your script is running from *.tBasic or *.tBasicC source through thincore (thinBasic.exe) or from bundled *.exe directly
    you will find out if you right click the link that starts it on the "suspicious reacting engine" and check the properties.

    for permanent solution follow the steps on the attached image where i suppose your script is running via thinCore from script source.
    If running from bundled exe it would be the exe-file then thats properties are to open in explorer and where you set "run as admin" for compatibility reasons...

    If it works, you might consider a script solution to be executed on all engines that makes either the bundled exe or *.tBasic-files run as admin always.
    if running from *.tBasic*-script-sources -and not to bother of different file extensions if crypted or special console files - i would suggest to run thinBasic.exe with elevated privileges always. Because its not possible to set for all users in one go (security feature of windows prevents to set administrator priviliges simply to HKEY_LOCAL_MACHINE ) you have to set it at least twice per computer.

    In any case to all existing users accounts and once to the .Default-users account - so in future every new account will inherit the setting. since only HKEY_USERS and HKEY_LOCAL_MACHINE can be accessed remotely but HKL_MACHINE will not accept generalized to run as admin always - as mentioned above -
    it were the most simple solution to inform all users via net broadcast to import a registry settings file - requires the same file locations on all machines.
    optional the thinbasic-script that creates the .reg-file can be run on every pc to provide the correct App_Path.

    '---Script created on 02-27-2021 04:52:37 by Me
    ' ### RegTBAsAdmin.tBasic ###
    
    
    
    
    ' this script will create 2 files:
    '- TbRunAsAdmin.reg
    '- Tb2RegImpAdmin.BAT
    
    ' goal: run thinBasic-scripts with elevated privileges
    
    
    ' usually it will succeed importing the regfile from thinbasic-script
    ' alternate option : create bundled exe of this that will run on each pc on your
    ' network (right-click + RunAs Admin)
    
    
    ' another option : if thinBasic-path or the optional other files are equal on all
    ' pcs you can use "Reg Import TbRunAsAdmin.reg" on elevated command prompt
                 
    string sRegFile = App_Scriptpath & "TbRunAsAdmin.REG"
    string sBatFile = App_Scriptpath & "Tb2RegImpAdmin.BAT"
    
    
    ' BACKSLASHES: \ in reg value name and in reg_[.]*sz data 
    '             must be escaped with a backslash and become: \\
    ' DOUBLE QUOTES: " within quoted strings will become:  \"
    
    
    string TBPath$ = replace$(App_path, "\", "!") ' do the backslash-thing
           TBPath$ = replace$(TBPath$, "!","\\") 
           
    string sCode = "Windows Registry Editor Version 5.00" & crlf & crlf 
    long turn
    		repeat
    		  incr turn
          sCode &= "[HKEY_" & choose$(turn,"CURRENT_USER", "USERS\.DEFAULT") 
          sCode &= "\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]" & crlf
    
    
    ' -- run tBasic-scripts as admin through permanently elevating thincore: 
         sCode &= $DQ & TBPath$ & "thinBasic.exe" & $DQ & "=" & $DQ & " ~RUNASADMIN" & $DQ & crlf 
    
    
    ' -- if users have access to thinAir uncomment the next line to allow saving anywhere:
          'sCode &= $DQ & TBPath$ & "thinAir\\thinAir.exe" & $DQ & "=" & $DQ & " ~RUNASADMIN" & $DQ & crlf 
    
    
    ' -- maybe some bundled exe that shall be executed as admin? 
    
    
    ' -- is it located at the same address network-wide?
           'sCode &= $DQ & "\\\\yourdomain\\network_location\\SharedFile.exe" & $DQ & "=" & $DQ & " ~RUNASADMIN" & $DQ & crlf 
    	
    ' -- or locally stored to all clients?:
          'sCode &= $DQ & "C:\\yourPath\\LocalFile.exe" & $DQ & "=" & $DQ & " ~RUNASADMIN" & $DQ & crlf 
    
    
    			sCode &= crlf 
    		until turn = 2
    		sCode &= string$(2, $spc)
    	' almost ready... registry uses UCS2-Le	encoding, 
    	' 16 Bit with Byte-Order-Mark (BOM) = FF FE
    	' sCode is plain ascii until here - lets convert!
    	long nChars = lenf(sCode)
    	
    	' allocate destination memory for Ucs2_Le:
    	' 2 Bytes BOM, 2 bytes per char 
    	
    	string AsUcs2_Le = mkbyt$(0xFF, 0xFE) & _       ' = BOM
    	                   repeat$(nChars,mkbyt$(0x20, 0x00)) 
    					'        just using count of 8 bit chars for 16-bit space-chars
    					
      '--  a virtual byte at the current - first - char of sCode to read it:
       dim bRead as Byte at strptr(sCode)  
     
      ' get position of the first char in destinations memory
       dword pos2Write = strptr(AsUcs2_Le)+2
    		
    		while nChars 
    			poke( byte, pos2Write, bRead )
    			' 1 char less to do:
    			decr nChars
    			' move the byte to read onto the next char:
    			SetAt(bRead, GetAt(bRead) + 1)
    			' go 2 bytes (skip 1 + go 1) forward at destination memory
    			pos2Write += 2
    		wend 
    		
    		' all converted, now save it to a REG-file next to this script
    		
    
    
        Save_File( sRegFile, AsUcs2_Le)
    	  AsUcs2_Le = Shell_CaptureOutput( "REG IMPORT " & $DQ & sRegFile & $DQ, "", %sw_Hide, 1500) & crlf 
    		
    		save_File( sBatFile, "Reg Import " & $DQ & sRegFile & $DQ & crlf & string$(3,$spc) )
    		
    	  if msgbox(AsUcs2_Le & "Is the result bad enough to try something else?", %MB_YesNo, "registry replies:") = %IDNO Then
    			msgbox ("Anyway you can run regedit as administrator and import" & crlf & sRegFile, %MB_IconInformation | %MB_OK, "Keep in mind:")
    			AsUcs2_Le ="..."
    		EndIf
    
    Attached Images Attached Images
    I think there are missing some Forum-sections as beta-testing and support

  10. #10
    Thanks for the detailed suggestion.

    We distribute this application via bundled .exe. The user does not have a shortcut or lnk file. They simply double click on the .exe. (The user has no idea that this .exe was made with ThinBasic.)

    I'm struggling a little bit to understand why administrator privileges would be required to get the ComputerName on just this one machine (out of many which run our .exe without admin).

    If running as admin does fix the problem, we would have to weigh this solution being fixed for one user compared to causing a lot of calls to customer support by people who are surprised that running our little updater app is asking them for admin privileges. That would likely generate a lot of extra worry in our users.

    Thanks again-

Page 1 of 2 12 LastLast

Similar Threads

  1. Call DWord... etc
    By David in forum thinBasic General
    Replies: 5
    Last Post: 25-10-2013, 09:20
  2. call statement
    By TomLebowski in forum thinBasic General
    Replies: 7
    Last Post: 17-08-2010, 21:39
  3. call dll
    By Lionheart008 in forum thinBasic General
    Replies: 6
    Last Post: 30-11-2009, 16:07

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •