OVH Cloud OVH Cloud

Copie de fichier au démarrage

5 réponses
Avatar
Informatique_LIDV
Bonjour,

J'ai un executable (créé en VB) qui se lance au démarrage du PC. Je l'ai
modifié et je souhaite copier la nouvelle version dans un script de
démarrage.
Le problème, c'est que, ce qui se trouve dans le programme de démarrage se
lance avant mon script. Le fichier étant ouvert, je ne peux faire la copie.
La solution serait de le faire à la main mais j'ai plus de 80 PC à faire
donc si vous avez une idée, ça m'arrangerait bien ...

Merci pour votre aide

Laëtitia

5 réponses

Avatar
Gloops
Bonjour,

Est-ce qu'il n'y aurait pas moyen de désactiver le lancement du script
(par clef de registre je suppose ?), redémarrer, faire la copie,
réactiver le lancement du script, redémarrer ?

Au début du processus on invite l'utilisateur à aller boire un café :)
________________________________________________
Informatique_LIDV a écrit, le 10/11/2005 09:11 :

Bonjour,

J'ai un executable (créé en VB) qui se lance au démarrage du PC. Je l'ai
modifié et je souhaite copier la nouvelle version dans un script de
démarrage.
Le problème, c'est que, ce qui se trouve dans le programme de démarrage se
lance avant mon script. Le fichier étant ouvert, je ne peux faire la copie.
La solution serait de le faire à la main mais j'ai plus de 80 PC à faire
donc si vous avez une idée, ça m'arrangerait bien ...

Merci pour votre aide

Laëtitia




Avatar
Clive Lumb
"Informatique_LIDV" a écrit dans le
message de news:
Bonjour,

J'ai un executable (créé en VB) qui se lance au démarrage du PC. Je l'ai
modifié et je souhaite copier la nouvelle version dans un script de
démarrage.
Le problème, c'est que, ce qui se trouve dans le programme de démarrage se
lance avant mon script. Le fichier étant ouvert, je ne peux faire la


copie.
La solution serait de le faire à la main mais j'ai plus de 80 PC à faire
donc si vous avez une idée, ça m'arrangerait bien ...

Merci pour votre aide

Laëtitia



Bonjour Laetitia,

D'après ton pseudo (informitique_LIDV) je soupçonne que tu es de Vichy comme
moi...
Ci-après un bout de code "tel quel" que j'utilise pour installer/mettre à
jour un petit programme d'affichage de messages.
Il detecte s'il est déjà installé, si ou, vérifie la version.
Si la version est plus ancienne, il tue le processus et remplace les
fichiers.
Ensuite il le relance.

Bon courage
Clive


Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Sub InstallPopUp()
Dim d As New cRegistry 'class cRegistry de vbAccelerator/Steve McMahon
Dim msg As String
Dim FSource As String
Dim FDest As String
'Dim Vals() As String
'Dim Valcount As Long
Dim i As Integer
Dim Flag As Boolean
Dim SourcePath As String
Dim AppPath As String
Dim AppName As String
Dim CurrentVersion As String
Dim LatestVersion As String
Dim hWindow As Long
Dim lngResult As Long
Dim lngReturnValue As Long
'Check to see if installed
'Look in
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun
fMainForm.sbStatusBar.Panels(1).Text = "Sediver Popup"
With d
.ClassKey = HKEY_LOCAL_MACHINE
.SectionKey = "SOFTWAREMicrosoftWindowsCurrentVersionRun"
.ValueKey = "Sediver PopUp"
Debug.Print .EnumerateValues(Vals, Valcount)
Flag = False
For i = LBound(Vals) To UBound(Vals)
If Vals(i) = .ValueKey Then Flag = True
Next i
FSource = WorkingPath & "msvbvm60.dll"
FDest = GetSysDir & "msvbvm60.dll"
If Not FileExists(FDest) Then FileCopy FSource, FDest

FSource = WorkingPath & "VB6FR.DLL"
FDest = GetSysDir & "VB6FR.DLL"
If Not FileExists(FDest) Then FileCopy FSource, FDest

If Flag Then
'Do version check
fMainForm.sbStatusBar.Panels(1).Text = "SedPopUp version
check..."

SourcePath = WorkingPath & "SEDPOPUP"
AppPath = "C:SEDPOPUP"
AppName = "SEDPOPUP.exe"
CurrentVersion = AppPath & AppName
LatestVersion = SourcePath & AppName
CurrentVersion = GetVersion(CurrentVersion)
LatestVersion = GetVersion(LatestVersion)
If (AppPath <> SourcePath) Then
If LatestVersion = CurrentVersion Then
'Do nothing
Else
fMainForm.sbStatusBar.Panels(1).Text = "Killing SedPopUp
..."

hWindow = FindWindow(vbNullString, "SedPopUp")
lngReturnValue = PostMessage(hWindow, WM_CLOSE, vbNull,
vbNull)
lngResult = WaitForSingleObject(hWindow, INFINITE)

'Does the handle still exist?
DoEvents
Sleep 500
hWindow = FindWindow(vbNullString, "SedPopUp")
If IsWindow(hWindow) = 1 Then
'The handle still exists. Use the TerminateProcess
function
'to close all related processes to this handle. See the
'article for more information.
'MsgBox "Handle still exists."
Set d = Nothing
Exit Sub
Else
'Handle does not exist.
'Program closed. Can copy over files
On Error GoTo CantCopy
fMainForm.sbStatusBar.Panels(1).Text = "Updating
SedPopUp ..."
FSource = WorkingPath & "sedpopupsedpopup.exe"
FDest = "c:sedpopupsedpopup.exe"
FileCopy FSource, FDest
FSource = WorkingPath & "sedpopupmswinsck.dep"
FDest = "c:sedpopupmswinsck.dep"
FileCopy FSource, FDest
FSource = WorkingPath & "sedpopupmswinsck.ocx"
FDest = "c:sedpopupmswinsck.ocx"
FileCopy FSource, FDest
FSource = WorkingPath & "sedpopupmswinsck.oca"
FDest = "c:sedpopupmswinsck.oca"
FileCopy FSource, FDest
' Restart prog
msg = "c:sedpopupsedpopup.exe"
' laisser le temps pour la copie
Wait 5
Shell msg
On Error GoTo 0
End If
End If
End If


Else
'Not Installed, let's copy the files
' we copy the winsock controls to the app path so that we don't disturb
any system files

msg = "command.com /C MD c:sedpopup"
Debug.Print ShellAndWaitForTermination(msg)


'now let's add the entry to the "run" section of the registry
.ValueType = REG_SZ
.Value = "c:sedpopupsedpopup.exe"
.CreateKey
'now let's run it for this session
msg = "c:sedpopupsedpopup.exe"
Shell msg
End If
End With

Set d = Nothing
Exit Sub
Avatar
Gloops
Ah ça au moins c'est la classe, on évite la phase d'envoyer
l'utilisateur au café :)

Du moment qu'on n'interrompt pas le processus à un moment inapproprié ...
_________________________________________
Clive Lumb a écrit, le 10/11/2005 17:47 :
Bonjour Laetitia,

D'après ton pseudo (informitique_LIDV) je soupçonne que tu es de Vichy comme
moi...
Ci-après un bout de code "tel quel" que j'utilise pour installer/mettre à
jour un petit programme d'affichage de messages.
Il detecte s'il est déjà installé, si ou, vérifie la version.
Si la version est plus ancienne, il tue le processus et remplace les
fichiers.
Ensuite il le relance.

Bon courage
Clive


Avatar
Informatique_LIDV
Salut et merci à toi. Pourrais-tu m'envoyer le code de la classe cRegistry ?

Merci

Laëtitia

"Clive Lumb" a écrit dans le message
de news:

"Informatique_LIDV" a écrit dans le
message de news:
Bonjour,

J'ai un executable (créé en VB) qui se lance au démarrage du PC. Je l'ai
modifié et je souhaite copier la nouvelle version dans un script de
démarrage.
Le problème, c'est que, ce qui se trouve dans le programme de démarrage
se
lance avant mon script. Le fichier étant ouvert, je ne peux faire la


copie.
La solution serait de le faire à la main mais j'ai plus de 80 PC à faire
donc si vous avez une idée, ça m'arrangerait bien ...

Merci pour votre aide

Laëtitia



Bonjour Laetitia,

D'après ton pseudo (informitique_LIDV) je soupçonne que tu es de Vichy
comme
moi...
Ci-après un bout de code "tel quel" que j'utilise pour installer/mettre à
jour un petit programme d'affichage de messages.
Il detecte s'il est déjà installé, si ou, vérifie la version.
Si la version est plus ancienne, il tue le processus et remplace les
fichiers.
Ensuite il le relance.

Bon courage
Clive


Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Sub InstallPopUp()
Dim d As New cRegistry 'class cRegistry de vbAccelerator/Steve McMahon
Dim msg As String
Dim FSource As String
Dim FDest As String
'Dim Vals() As String
'Dim Valcount As Long
Dim i As Integer
Dim Flag As Boolean
Dim SourcePath As String
Dim AppPath As String
Dim AppName As String
Dim CurrentVersion As String
Dim LatestVersion As String
Dim hWindow As Long
Dim lngResult As Long
Dim lngReturnValue As Long
'Check to see if installed
'Look in
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun
fMainForm.sbStatusBar.Panels(1).Text = "Sediver Popup"
With d
.ClassKey = HKEY_LOCAL_MACHINE
.SectionKey = "SOFTWAREMicrosoftWindowsCurrentVersionRun"
.ValueKey = "Sediver PopUp"
Debug.Print .EnumerateValues(Vals, Valcount)
Flag = False
For i = LBound(Vals) To UBound(Vals)
If Vals(i) = .ValueKey Then Flag = True
Next i
FSource = WorkingPath & "msvbvm60.dll"
FDest = GetSysDir & "msvbvm60.dll"
If Not FileExists(FDest) Then FileCopy FSource, FDest

FSource = WorkingPath & "VB6FR.DLL"
FDest = GetSysDir & "VB6FR.DLL"
If Not FileExists(FDest) Then FileCopy FSource, FDest

If Flag Then
'Do version check
fMainForm.sbStatusBar.Panels(1).Text = "SedPopUp version
check..."

SourcePath = WorkingPath & "SEDPOPUP"
AppPath = "C:SEDPOPUP"
AppName = "SEDPOPUP.exe"
CurrentVersion = AppPath & AppName
LatestVersion = SourcePath & AppName
CurrentVersion = GetVersion(CurrentVersion)
LatestVersion = GetVersion(LatestVersion)
If (AppPath <> SourcePath) Then
If LatestVersion = CurrentVersion Then
'Do nothing
Else
fMainForm.sbStatusBar.Panels(1).Text = "Killing SedPopUp
..."

hWindow = FindWindow(vbNullString, "SedPopUp")
lngReturnValue = PostMessage(hWindow, WM_CLOSE, vbNull,
vbNull)
lngResult = WaitForSingleObject(hWindow, INFINITE)

'Does the handle still exist?
DoEvents
Sleep 500
hWindow = FindWindow(vbNullString, "SedPopUp")
If IsWindow(hWindow) = 1 Then
'The handle still exists. Use the TerminateProcess
function
'to close all related processes to this handle. See the
'article for more information.
'MsgBox "Handle still exists."
Set d = Nothing
Exit Sub
Else
'Handle does not exist.
'Program closed. Can copy over files
On Error GoTo CantCopy
fMainForm.sbStatusBar.Panels(1).Text = "Updating
SedPopUp ..."
FSource = WorkingPath & "sedpopupsedpopup.exe"
FDest = "c:sedpopupsedpopup.exe"
FileCopy FSource, FDest
FSource = WorkingPath & "sedpopupmswinsck.dep"
FDest = "c:sedpopupmswinsck.dep"
FileCopy FSource, FDest
FSource = WorkingPath & "sedpopupmswinsck.ocx"
FDest = "c:sedpopupmswinsck.ocx"
FileCopy FSource, FDest
FSource = WorkingPath & "sedpopupmswinsck.oca"
FDest = "c:sedpopupmswinsck.oca"
FileCopy FSource, FDest
' Restart prog
msg = "c:sedpopupsedpopup.exe"
' laisser le temps pour la copie
Wait 5
Shell msg
On Error GoTo 0
End If
End If
End If


Else
'Not Installed, let's copy the files
' we copy the winsock controls to the app path so that we don't disturb
any system files

msg = "command.com /C MD c:sedpopup"
Debug.Print ShellAndWaitForTermination(msg)


'now let's add the entry to the "run" section of the registry
.ValueType = REG_SZ
.Value = "c:sedpopupsedpopup.exe"
.CreateKey
'now let's run it for this session
msg = "c:sedpopupsedpopup.exe"
Shell msg
End If
End With

Set d = Nothing
Exit Sub




Avatar
Clive Lumb
Tu le trouveras ici
http://www.vbaccelerator.com/codelib/inireg/registry.htm



"Informatique_LIDV" a écrit dans le
message de news:
Salut et merci à toi. Pourrais-tu m'envoyer le code de la classe cRegistry


?

Merci

Laëtitia

"Clive Lumb" a écrit dans le


message
de news:
>
> "Informatique_LIDV" a écrit dans le
> message de news:
>> Bonjour,
>>
>> J'ai un executable (créé en VB) qui se lance au démarrage du PC. Je


l'ai
>> modifié et je souhaite copier la nouvelle version dans un script de
>> démarrage.
>> Le problème, c'est que, ce qui se trouve dans le programme de démarrage
>> se
>> lance avant mon script. Le fichier étant ouvert, je ne peux faire la
> copie.
>> La solution serait de le faire à la main mais j'ai plus de 80 PC à


faire
>> donc si vous avez une idée, ça m'arrangerait bien ...
>>
>> Merci pour votre aide
>>
>> Laëtitia
>>
> Bonjour Laetitia,
>
> D'après ton pseudo (informitique_LIDV) je soupçonne que tu es de Vichy
> comme
> moi...
> Ci-après un bout de code "tel quel" que j'utilise pour installer/mettre


à
> jour un petit programme d'affichage de messages.
> Il detecte s'il est déjà installé, si ou, vérifie la version.
> Si la version est plus ancienne, il tue le processus et remplace les
> fichiers.
> Ensuite il le relance.
>
> Bon courage
> Clive
>
>
> Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
>
> Public Sub InstallPopUp()
> Dim d As New cRegistry 'class cRegistry de vbAccelerator/Steve McMahon
> Dim msg As String
> Dim FSource As String
> Dim FDest As String
> 'Dim Vals() As String
> 'Dim Valcount As Long
> Dim i As Integer
> Dim Flag As Boolean
> Dim SourcePath As String
> Dim AppPath As String
> Dim AppName As String
> Dim CurrentVersion As String
> Dim LatestVersion As String
> Dim hWindow As Long
> Dim lngResult As Long
> Dim lngReturnValue As Long
> 'Check to see if installed
> 'Look in
> HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun
> fMainForm.sbStatusBar.Panels(1).Text = "Sediver Popup"
> With d
> .ClassKey = HKEY_LOCAL_MACHINE
> .SectionKey = "SOFTWAREMicrosoftWindowsCurrentVersionRun"
> .ValueKey = "Sediver PopUp"
> Debug.Print .EnumerateValues(Vals, Valcount)
> Flag = False
> For i = LBound(Vals) To UBound(Vals)
> If Vals(i) = .ValueKey Then Flag = True
> Next i
> FSource = WorkingPath & "msvbvm60.dll"
> FDest = GetSysDir & "msvbvm60.dll"
> If Not FileExists(FDest) Then FileCopy FSource, FDest
>
> FSource = WorkingPath & "VB6FR.DLL"
> FDest = GetSysDir & "VB6FR.DLL"
> If Not FileExists(FDest) Then FileCopy FSource, FDest
>
> If Flag Then
> 'Do version check
> fMainForm.sbStatusBar.Panels(1).Text = "SedPopUp version
> check..."
>
> SourcePath = WorkingPath & "SEDPOPUP"
> AppPath = "C:SEDPOPUP"
> AppName = "SEDPOPUP.exe"
> CurrentVersion = AppPath & AppName
> LatestVersion = SourcePath & AppName
> CurrentVersion = GetVersion(CurrentVersion)
> LatestVersion = GetVersion(LatestVersion)
> If (AppPath <> SourcePath) Then
> If LatestVersion = CurrentVersion Then
> 'Do nothing
> Else
> fMainForm.sbStatusBar.Panels(1).Text = "Killing SedPopUp
> ..."
>
> hWindow = FindWindow(vbNullString, "SedPopUp")
> lngReturnValue = PostMessage(hWindow, WM_CLOSE, vbNull,
> vbNull)
> lngResult = WaitForSingleObject(hWindow, INFINITE)
>
> 'Does the handle still exist?
> DoEvents
> Sleep 500
> hWindow = FindWindow(vbNullString, "SedPopUp")
> If IsWindow(hWindow) = 1 Then
> 'The handle still exists. Use the TerminateProcess
> function
> 'to close all related processes to this handle. See


the
> 'article for more information.
> 'MsgBox "Handle still exists."
> Set d = Nothing
> Exit Sub
> Else
> 'Handle does not exist.
> 'Program closed. Can copy over files
> On Error GoTo CantCopy
> fMainForm.sbStatusBar.Panels(1).Text = "Updating
> SedPopUp ..."
> FSource = WorkingPath & "sedpopupsedpopup.exe"
> FDest = "c:sedpopupsedpopup.exe"
> FileCopy FSource, FDest
> FSource = WorkingPath & "sedpopupmswinsck.dep"
> FDest = "c:sedpopupmswinsck.dep"
> FileCopy FSource, FDest
> FSource = WorkingPath & "sedpopupmswinsck.ocx"
> FDest = "c:sedpopupmswinsck.ocx"
> FileCopy FSource, FDest
> FSource = WorkingPath & "sedpopupmswinsck.oca"
> FDest = "c:sedpopupmswinsck.oca"
> FileCopy FSource, FDest
> ' Restart prog
> msg = "c:sedpopupsedpopup.exe"
> ' laisser le temps pour la copie
> Wait 5
> Shell msg
> On Error GoTo 0
> End If
> End If
> End If
>
>
> Else
> 'Not Installed, let's copy the files
> ' we copy the winsock controls to the app path so that we don't


disturb
> any system files
>
> msg = "command.com /C MD c:sedpopup"
> Debug.Print ShellAndWaitForTermination(msg)
>
>
> 'now let's add the entry to the "run" section of the registry
> .ValueType = REG_SZ
> .Value = "c:sedpopupsedpopup.exe"
> .CreateKey
> 'now let's run it for this session
> msg = "c:sedpopupsedpopup.exe"
> Shell msg
> End If
> End With
>
> Set d = Nothing
> Exit Sub
>
>