Toon posts:

[VB] CurrentDir lijkt niet te werken icm spaties in de naam

Pagina: 1
Acties:

Verwijderd

Topicstarter
Voor het opstarten van een applicatie gebruikt een klant van ons het onderstaande VB-script. Dit script werkt goed in de testomgeving, maar geeft problemen in de productieomgeving. Enige verschil is dat in de productieomgeving spaties voorkomen in de naam van de applicatiemap. We hebben het ook getest door een mapping te maken direct naar de map met bestanden, dan gaat het wel goed.
Ook het plaatsen van " om de term CurrentDir helpt niet. Iemand ideeen ?

Het lijkt erop dat de variable currentdir alleen werkt met driveletters en niet met UNC paden, is hier een andere manier voor ?

Gaat om het volgende script :

Dim WSHfso
Dim CurrentDir
Dim strTrail
Dim strNewAppShorcutFolder
Dim strOldAppShorcutFolder01
Dim strOldAppShorcutFolder02
Dim strAlluserProfile

Set WSHfso = WScript.CreateObject("Scripting.FileSystemObject")
CurrentDir = WSHfso.GetAbsolutePathName(".\")
strTrail = Right(CurrentDir, 1)
If strTrail = "\" Then
CurrentDir = Left(CurrentDir, Len(CurrentDir)-1)
End If

'Starten installatie
Set WSHShell = CreateObject("WScript.Shell")
strAlluserProfile = WSHShell.ExpandEnvironmentStrings("%ALLUSERSPROFILE%") & "\Start Menu\Programs"
fllRunCommand = WSHShell.Run(CurrentDir & "\setup.exe -if installer.ini")

'Wachten tot installatieproces is afgerond
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Do
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'setup.exe'")
Loop Until colProcessList.count = 0
Set objWMIService=Nothing

'cleanup shortcuts

'Starten verwijder shortcut
Set WSHShell = CreateObject("WScript.Shell")
fllRunCommand = WSHShell.Run(CurrentDir & "\shortcut.bat /c")

Set WSHfso = Nothing

Het script geeft in de productieomgeving nu de volgende foutmelding :

Script : \\servernaam\applicatienaam\script.vbs
regel :19
teken : 1
fot : kan het netwerkpad niet vinden
code 80070035
bron : null

[ Voor 21% gewijzigd door Verwijderd op 27-06-2005 14:11 ]


  • Brahiewahiewa
  • Registratie: Oktober 2001
  • Laatst online: 30-09-2022

Brahiewahiewa

boelkloedig

Kan in de FAQ: directory paths met spaties moeten in quotjes:
Visual Basic:
1
fllRunCommand = WSHShell.Run ( """ & CurrentDir & "\setup.exe" & """ & " -if installer.ini"  )
en
Visual Basic:
1
fllRunCommand = WSHShell.Run ( """ & CurrentDir & "\shortcut.bat" & """ & " /c" )

[ Voor 51% gewijzigd door Brahiewahiewa op 27-06-2005 15:12 ]

QnJhaGlld2FoaWV3YQ==


  • Mickman
  • Registratie: Juni 2001
  • Laatst online: 29-03 18:11
Goh, dit script komt me bekend voor. Je hebt zelfs mijn naamgevingen gebruikt :)
Reaal toevallig?

Je moet dubbele quotes gebruiken voor paden met spaties. ("""" & pad & """")

  • Fish
  • Registratie: Juli 2002
  • Niet online

Fish

How much is the fish

of anders "progra~1" ip "program files"

[ Voor 31% gewijzigd door Fish op 27-06-2005 23:09 ]

Iperf