prosty scenariusz: skrypt logowania, uruchamiający bginfo. podstawowy problem w vbs: obsługa katalogów ze spacją. niestety przekazanie “c:program filessysteinternalsbginfo.exe” z podobnie wyglądającymi parametrami jest upierdliwe – ile tych cholernych cudzysłowów jest potrzebne?

WShell.run """"&SUPPORT_DIR&"bginfo.exe"" """&SUPPORT_DIR&"wrkstations.bgi"" /accepteula /timer:0"

a cały skrypcik wygląda tak:

'*******************************************************************************
'*  prepare server environment - processexplorer and bginfo on servers         *
'*                                                                             *
'*    author:         nexorek[at]gmail.com                                     *
'*                             last change  25.o5.2kd                          *
'*                                                                             *
'*******************************************************************************

OPTION EXPLICIT
ON ERROR RESUME NEXT
CONST SERVER_DIR="\FILESERVERgpofiles$"
Dim SUPPORT_DIR
Dim FSO, file
Dim WShell

'*******************************************************************************
'*                                 MAIN                                        *
'*******************************************************************************
set FSO=CreateObject("Scripting.FileSystemObject")
Set WShell = WScript.CreateObject("WScript.Shell")
SUPPORT_DIR=WShell.ExpandEnvironmentStrings("%programfiles%")&"sysinternals"
'check admin directory
if not FSO.FolderExists( SUPPORT_DIR ) then
  FSO.CreateFolder( SUPPORT_DIR )
end if
'copy if not exist
iFCopy("bginfo.exe")
iFCopy("wrkstations.bgi")
iFCopy("procexp.exe")
WShell.run """"&SUPPORT_DIR&"bginfo.exe"" """&SUPPORT_DIR&"wrkstations.bgi"" /accepteula /timer:0"


'*******************************************************************************
'*                              SUBS'N'FUNCS                                   *
'*******************************************************************************
Sub iFCopy(sourceFile)
  if not FSO.FileExists( SUPPORT_DIR&sourceFile ) then
    FSO.copyFile (SERVER_DIR&sourceFile), SUPPORT_DIR, true
  else
   'check version
    if strcomp( FSO.getFileVersion(SERVER_DIR&sourceFile),FSO.getFileVersion(SUPPORT_DIR&sourceFile) )<>0 then
      FSO.copyFile (SERVER_DIR&source), SUPPORT_DIR, true
    end if
  end if
End Sub

eN.

-o((:: sprEad the l0ve ::))o-

Zostaw komentarz

Twój adres e-mail nie zostanie opublikowany. Wymagane pola są oznaczone *

Time limit is exhausted. Please reload CAPTCHA.