Jump to content

The system cannot find the file specified


Recommended Posts

Note:** My original post may have been to long and put people off. See post #3 for the very brief version of my issue with this message when accessing the registry.

Hey all, I have a script that runs when people log into our Novell network. We are logging into novell first then the workstation autologs in using a set account with administrative and user rights. Most accounts are only part of a workgroup, but some may be on a domain, though it doesn't seem to matter.

Anyway, I am logging printer information from the registry, saving it into c:\windows\prtinfo.ini, then copying it to the network with the workstation name. However, sometimes (about every 1 out of 5 PCs) gets this error message doing RegRead for the Printers section "The system cannot find the file specified". I was initially checking "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers" but thought maybe the error was that there wasn't system access available yet to the workstation registry or (after reading MS Technet), perhaps that portion of the registry hadn't been cloned yet. Then I changed it to ControlSet001 but the error still came up.

I then added a three second wait to allow the workstation to authenticate and/or the registry to clone but it hasn't seemed to make a difference.

I did see that whenever a PC had the error and has logged in, I would run the script manually (one time on five different PCs) and it always works.

Here is the code. My error checking is rather bulky (in the output file) but not too long. I also am including a good output, and a bad output from the same PC.

Thanks in advance.

;Format for prtinfo.ini files
;[PrinterIPPorts]
;Port[1 to ...]=[IP address]
;[Printers]
;Printer[1 to ...]=[Name]
;[Printer#] (from Printers)
;Printer Name=[Name]
;PortIP=[IP Address]
;PortName=[Port]
;ShareName=[Share Name]
;Driver=[Printer Driver]
;Print Processor=[Print Processor]
;.="******************************";This is just used as a separator line
; standard options for MOST routines;default value is listed first
;$Start=TimerInit()
#Include <GuiConstants.au3>
Opt("MouseCoordMode",1);1=absolute, 0=relative, 2=client
;Opt("TrayIconHide",1);0=show, 1=hide tray icon
;Opt("TrayIconDebug",1);0=no debug, 1 = show debug
Opt("WinDetectHiddenText",1);0=don't detect, 1=do detect
Opt("WinTitleMatchMode",4);1=start, 2=subStr, 3=exact, 4=advanced
;Opt("WinWaitDelay",100);250 milliseconds
;Remove all previous .ini data because printers can change.  Also chose this
; rather than delete the file because deleting a file increaseses the
; purge files space on the Novell server.
Dim $errors[20]
$v_SleepCount=0
If FileExists("C:\windows\prtinfo.ini") Then
    If FileGetSize("C:\windows\prtinfo.ini") >20000 Then
        FileDelete("C:\windows\prtinfo.ini")
    Else
        $ini_SecList=IniReadSectionNames("c:\windows\prtinfo.ini")
        $count=$ini_SecList[0]
        While $count
            IniDelete("C:\windows\prtinfo.ini",$ini_SecList[$count])
            $count-=1
        WEnd
    EndIf
EndIf
;For posting purposes, change server path to directory to save .ini files
Global $DirPath="\\[server path]"
$Maindir = "C:"
$NETDIR=@ScriptDir
$str_LogPath=""
$reg_PortKey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports"
$reg_PrintKey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers"
$v_PortCount=1
While $v_PortCount
    $reg_PortName=RegEnumKey($reg_PortKey,$v_PortCount)
    $err=@error

;***************** Start Troubleshooting section - Delete after done
IniWrite("C:\windows\prtinfo.ini","ErrorsIPPorts","@error"&$v_PortCount,$err)
IniWrite("C:\windows\prtinfo.ini","ErrorsIPPorts","ErrorData"&$v_PortCount,$reg_PortName&", "&$reg_PortKey&"\"&$v_PortCount)
If $v_PortCount>30 Then $err=-1
;***************** End Troubleshooting section - Delete after done

    If $err=-1 Then
        IniWrite("C:\windows\prtinfo.ini","PrinterIPPorts",".","****************************************")
        ExitLoop
    Else
        $reg_PortIP=RegRead($reg_PortKey & "\" & $reg_PortName, "IPAddress")
    EndIf
;   MsgBox(0,"","Reg value=" & $reg_PortIP & @CRLF & "Error=" & $err)
    IniWrite("c:\windows\prtinfo.ini", "PrinterIPPorts", "Port"&$v_PortCount,$reg_PortIP)
    $v_PortCount+=1
WEnd

$v_PrintCount=1
While $v_PrintCount
    $reg_PrintName=RegEnumKey($reg_PrintKey,$v_PrintCount)
    $err=@error
;   $err=1;This is here to test this loop.  Delete when done.
    If $err = 1 Then
        $v_SleepCount=3
        While $v_SleepCount
            Sleep(1000)
            $reg_PrintName=RegEnumKey($reg_PrintKey,$v_PrintCount)
            $err=@error
;           If $v_SleepCount>1 Then $err=1;This is here to test this loop.  Delete when done.
            If $err <> 1 Then ExitLoop
            $v_SleepCount-=1
        WEnd
    EndIf
;***************** Start Troubleshooting section - Delete after done
IniWrite("C:\windows\prtinfo.ini","ErrorsPrinters","@error"&$v_PrintCount,$err&","&$v_SleepCount)
IniWrite("C:\windows\prtinfo.ini","ErrorsPrinters","ErrorData"&$v_PrintCount,$reg_PrintName&", "&$reg_PrintKey&"\"&$v_PrintCount)
If $v_PrintCount>20 Then $err=-1
;***************** End Troubleshooting section - Delete after done

;   MsgBox(0,"","Reg value=" & $reg_PrintName & @CRLF & "Error=" & $err & @CRLF & "Count=" & $v_PrintCount)
    If $err=-1 Then
        IniWrite("C:\windows\prtinfo.ini","Printers",".","****************************************")
        ExitLoop
    EndIf
    $reg_Port=RegRead($reg_PrintKey&"\"&$reg_PrintName,"Port")
    $reg_PortIP=RegRead($reg_PortKey&"\"&$reg_Port,"IPAddress")
    $reg_ShareName=RegRead($reg_PrintKey&"\"&$reg_PrintName,"Share Name")
    $reg_Driver=RegRead($reg_PrintKey&"\"&$reg_PrintName,"Printer Driver")
    $reg_PrtProc=RegRead($reg_PrintKey&"\"&$reg_PrintName,"Print Processor")
;   MsgBox(0,"","Reg value=" & $reg_PrintName & @CRLF & "Error=" & $err)
;Section
    IniWrite("C:\windows\prtinfo.ini","Printers","Printer"&$v_PrintCount,$reg_PrintName)
;Values
    IniWrite("C:\windows\prtinfo.ini","Printer"&$v_PrintCount,"Printer Name",$reg_PrintName)
    IniWrite("C:\windows\prtinfo.ini","Printer"&$v_PrintCount,"PortIP",$reg_PortIP)
    IniWrite("C:\windows\prtinfo.ini","Printer"&$v_PrintCount,"PortName",$reg_Port)
    IniWrite("C:\windows\prtinfo.ini","Printer"&$v_PrintCount,"ShareName",$reg_ShareName)
    IniWrite("C:\windows\prtinfo.ini","Printer"&$v_PrintCount,"Driver",$reg_Driver)
    IniWrite("C:\windows\prtinfo.ini","Printer"&$v_PrintCount,"Print Processor",$reg_PrtProc)
    IniWrite("C:\windows\prtinfo.ini","Printer"&$v_PrintCount,".","****************************************")
    $v_PrintCount+=1
WEnd
;$TimeDiff=TimerDiff($start)
FileCopy("c:\windows\prtinfo.ini", $DirPath & "\logs\printers\" & @ComputerName & ".ini", 1)
;MsgBox(0,"Time to run this script","Create .ini file=" & $TimeDiff & @CRLF & "Time until this message box=" & TimerDiff($start))

Bad output

[ErrorsIPPorts]

@error1=0

ErrorData1=IP_10.12.12.105, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\1

@error2=0

ErrorData2=IP_10.12.12.42, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\2

@error3=-1

ErrorData3=No more data is available.

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\3

[PrinterIPPorts]

Port1=10.12.12.105

Port2=10.12.12.42

.=****************************************

[ErrorsPrinters]

@error1=1,0

ErrorData1=The system cannot find the file specified.

@error2=1,0

ErrorData2=The system cannot find the file specified.

@error3=1,0

ErrorData3=The system cannot find the file specified.

@error4=1,0

ErrorData4=The system cannot find the file specified.

@error5=1,0

ErrorData5=The system cannot find the file specified.

@error6=1,0

ErrorData6=The system cannot find the file specified.

@error7=1,0

ErrorData7=The system cannot find the file specified.

@error8=1,0

ErrorData8=The system cannot find the file specified.

@error9=1,0

ErrorData9=The system cannot find the file specified.

@error10=1,0

ErrorData10=The system cannot find the file specified.

@error11=-1,1

ErrorData11=No more data is available.

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\11

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\10

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\9

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\8

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\7

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\6

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\5

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\4

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\3

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\2

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\1

[Printers]

Printer1=The system cannot find the file specified.

Printer2=The system cannot find the file specified.

Printer3=The system cannot find the file specified.

Printer4=The system cannot find the file specified.

Printer5=The system cannot find the file specified.

Printer6=The system cannot find the file specified.

Printer7=The system cannot find the file specified.

Printer8=The system cannot find the file specified.

Printer9=The system cannot find the file specified.

Printer10=The system cannot find the file specified.

.=****************************************

<there were 10 blank lines here I deleted here>

[Printer1]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

[Printer2]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

[Printer3]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

[Printer4]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

[Printer5]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

[Printer6]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

[Printer7]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

[Printer8]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

[Printer9]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

[Printer10]

Printer Name=The system cannot find the file specified.

PortIP=

PortName=

ShareName=

Driver=

Print Processor=

.=****************************************

Good output

[ErrorsIPPorts]

@error1=0

ErrorData1=IP_10.12.12.105, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\1

@error2=0

ErrorData2=IP_10.12.12.42, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\2

@error3=-1

ErrorData3=No more data is available.

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports\3

[PrinterIPPorts]

Port1=10.12.12.105

Port2=10.12.12.42

.=****************************************

[ErrorsPrinters]

@error1=0,0

ErrorData1=Carls_HP LaserJet 4 Plus, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\1

@error2=0,0

ErrorData2=HP LaserJet 4 Plus, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\2

@error3=-1,0

ErrorData3=No more data is available.

, HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Printers\3

[Printers]

Printer1=Carls_HP LaserJet 4 Plus

Printer2=HP LaserJet 4 Plus

.=****************************************

[Printer1]

Printer Name=Carls_HP LaserJet 4 Plus

PortIP=10.12.12.42

PortName=IP_10.12.12.42

ShareName=

Driver=HP LaserJet 4 Plus

Print Processor=WinPrint

.=****************************************

[Printer2]

Printer Name=HP LaserJet 4 Plus

PortIP=10.12.12.105

PortName=IP_10.12.12.105

ShareName=

Driver=HP LaserJet 4 Plus

Print Processor=WinPrint

.=****************************************

Edited by LostUser

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
Share on other sites

Just want to bring this post back up as I still have no resolution. Maybe my first post was a little to long.

Basically, I get this 'The system cannot find the file specified' message when using regread. However it doesn't happen all the time. Everytime I run it on a machine after it is logged in, it works fine. It only happens (on occasion) when someone is logging into the network.

It doesn't seem to ever happen on this first registry key in the script:

$reg_PortKey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports"

Yet it happens on this one about every fifth workstation on login:

$reg_PrintKey="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers"

Any ideas?

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
Share on other sites

  • 3 weeks later...

Hi again, I still don't have a resolution to this issue. I was hoping for some insight from someone.

Anyone? See post #3 for a brief description of the problem.

Thanks

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
Share on other sites

  • 2 weeks later...

Hi again, I still don't have a resolution to this issue. I was hoping for some insight from someone.

Anyone? See post #3 for a brief description of the problem.

Thanks

Is this posting the record for the most posts to a credible issue with only the author replying andalso posting a solution?

Anyway, I was able to work through the problem. At the point where I am using RegEnumKey to read the key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers", the error occurs because that key doesn't exist yet. So I guess that it IS the registry hive not merging before the script checks the specific registry locations.

What I did was put in a count down timer from 60 (seconds) for 60 times to try to read the registry. If I the script is able to read the registry before the 60 seconds is up, I record the time and error number (always 0 now) and continue on with the script. If the script goes longer than 60 seconds then I abort the script (my choice).

Read on if you are bored ... ;)

I can only guess why a RegEnum for the registry key gives 'The system cannot find the file specified' error. If I assume the wording of this error is accurate, then the RegEnum command is being pointed to a file having the location of the registry key which may, in fact, be a .dat (user.dat?) file somewhere but doesn't exist yet.

Or that it is trying to read a specific point past the end of a file knowing that there will soon exist a location at that spot past the end of file but it doesn't exist yet? Does that make sense? Am I rambling? I don't know. Does it matter anymore now that I have solved my own problem? Am I living my dreams or are my dreams really my life?

Maybe someone else can explain it to me if this isn't accurate.

Anyway, my thanks to me for helping me with my problem. I award me 10,000 points but like new math in 1st grade, the numbers don't really matter.

Aloha

Edited by LostUser

Be open minded but not gullible.A hammer sees everything as a nail ... so don't be A tool ... be many tools.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...