Microsoft VBScript运行时错误:找不到路径

时间:2017-02-14 10:43:48

标签: vbscript

我想执行一个vbs脚本,该脚本为我提供给定文件夹的大小,但在执行时它会返回错误:

  

Microsoft VBScript运行时错误:找不到路径

以前,错误是

  

Microsoft VBScript运行时错误:权限被拒绝

但在这些命令之后:

takeown /f C:\Users /r /d y                          
icacls C:\Users /grant administrators:F /T 

它变成了“找不到路径”。如您所见,我想要的文件夹大小为C:\Users

这是我的代码:

'Created the 18.03.2010
'Easy script for check space folder. You need NRPE_NT daemon on win computer
'##########################################################'
'Install'
'##########################################################'
'1.copy file to c:\ for example... c:\nrpe_nt\bin\check_folder_size.vbs'
'2.set your nrpe.cfg for command for example 
'command[check_foldersize]=c:\windows\system32\cscript.exe //NoLogo //T:30 c:\nrpe_nt\bin\check_folder_size.vbs c:\yourfolder 50 78
'50 70 are parameters for warning and critical value in MB'
'3.restart your nrpe_nt daemon in command prompt example.. net stop nrpe_nt and net start nrpe_nt'
'4. try from linux example.: ./check_nrpe -H yourcomputer -c check_foldersize and result can be OK:22,8 MB'
'it is all'
'##########################################################'
Dim strfolder
Dim intwarning
Dim intcritic
Dim wsh
Dim intvelkost
Dim intjednotka
'##########################################################'
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wsh = CreateObject("WScript.Shell")
'##########################################################'
If WScript.Arguments.Count = 3 Then
  strfolder  = WScript.Arguments(0)
  intwarning = WScript.Arguments(1)
  intcritic  = WScript.Arguments(2)

  Set objFolder = objFSO.GetFolder(strfolder)
  intjednotka = 1048576 '1MB->bytes'
  intvelkost = objFolder.Size/intjednotka

  If (objFolder.Size/1048576) > CInt(intwarning) Then  
    WScript.Echo "WARNING:" & round (objFolder.Size / 1048576,1) & " MB"
    WScript.Quit(1)
  ElseIf (objFolder.Size/1024000) > CInt(intcritic) Then  
    WScript.Echo "CRITICAL:" & Round(objFolder.Size / 1048576,1) & " MB"
    WScript.Quit(2)
  Else
    WScript.Echo "OK:" & Round(objFolder.Size /1048576,1) & " MB"
    WScript.Quit(0)
  End If
Else
  WScript.Echo "UNKNOWN:"& strfolder &"-" & intwarning & "-" & intcritic
  WScript.Quit(3)
End If

脚本调用的行:

check_foldersize = cscript.exe //nologo //T:60 scripts\check_folder_size.vbs C:\Users 4000 5000 

编辑:还有一点:当我将文件夹C:\ Users更改为C:\ Intel时没有错误。所以它似乎是一个链接到Users文件夹本身的问题。然后我不认为iis_iusrs权限是原因。

0 个答案:

没有答案