Thomas_Meyer
asked on
How to copy and run the file from the server using VB script?
Hi Experts,
I need help with simple vb script, which is responsible for:
- Check whether one of two possible locations are set:
C:\Program Files (x86)\GIMP-2.0\bin\gimp-co nsole-2.6. exe
or
C:\Program Files\GIMP-2.0\bin\ gimp-console-2.6.exe
If the script finds the file, and must be stopped. If the file is not found, so as to:
- From the server, copy the executable file ("\\S3\i$\Gimp\gimp-June 2 11-i686-setup-1.exe") to a local temporary folder - ExpandEnvironmentStrings ("%Temp%")
- Run the exe file copied using the command:
Thank you in advance for any help.
TM
I need help with simple vb script, which is responsible for:
- Check whether one of two possible locations are set:
C:\Program Files (x86)\GIMP-2.0\bin\gimp-co
or
C:\Program Files\GIMP-2.0\bin\ gimp-console-2.6.exe
If the script finds the file, and must be stopped. If the file is not found, so as to:
- From the server, copy the executable file ("\\S3\i$\Gimp\gimp-June 2 11-i686-setup-1.exe") to a local temporary folder - ExpandEnvironmentStrings ("%Temp%")
- Run the exe file copied using the command:
runas /user:mydomain@user /mypassword %TMP%\gimp-June 2 11-i686-setup-1.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART
- Finally, after installing the script delete the exe file from the Windows temporary folder.Thank you in advance for any help.
TM
Ok let's see if I understand. If "gimp-console-2.6.exe" process is running, must be stopped first?
ASKER
No, the first requirement applies only checks whether the program is no longer the "GIMP" installed on the computer (verify the existence of a file in the specified locations). If the executable file exists either in "C:\Program Files\ ..." for 32-bit operating systems, or "C:\Program Files (x86)\ ..." for 64-bit operating systems, so the script must end. If these files do not exist the script should proceed to the second point - that is, copy the installation file.
Ok, try this script:
Dim objWSH, objFSO, x86Path, x64Path, SetupPath, TempPath
Set objWSH = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
x86Path = """C:\Program Files\GIMP-2.0\bin\gimp-console-2.6.exe"""
x64Path = """C:\Program Files (x86)\GIMP-2.0\bin\gimp-console-2.6.exe"""
SetupPath = """\\S3\i$\Gimp\gimp-June 2 11-i686-setup-1.exe"""
TempPath = objWSH.ExpandEnvironmentStrings(%temp%)
If objFSO.FileExists(x86Path) or objFSO.FileExists(x64Path) Then
WScript.Quit
Else
objFSO.CopyFile SetupPath, TempPath
objWSH.Run "cmd.exe /C runas /user:mydomain@user /mypassword " & TempPath &_
"\gimp-June 2 11-i686-setup-1.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART"
ASKER
When you run the script, the script writes an error to 15 line, missing command 'End':
Dim objWSH, objFSO, x86Path, x64Path, SetupPath, TempPath
Set objWSH = WScript.CreateObject("WScr ipt.Shell" )
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
x86Path = """C:\Program Files\GIMP-2.0\bin\gimp-co nsole-2.6. exe"""
x64Path = """C:\Program Files (x86)\GIMP-2.0\bin\gimp-co nsole-2.6. exe"""
SetupPath = """\\S3\i$\Gimp\gimp-June 2 11-i686-setup-1.exe"""
TempPath = objWSH.ExpandEnvironmentSt rings("%te mp%")
If objFSO.FileExists(x86Path) or objFSO.FileExists(x64Path) Then
WScript.Quit
Else
objFSO.CopyFile SetupPath, TempPath
objWSH.Run "cmd.exe /C runas /user:mydomain@user /mypassword " & TempPath &_
"\gimp-June 2 11-i686-setup-1.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART"
Dim objWSH, objFSO, x86Path, x64Path, SetupPath, TempPath
Set objWSH = WScript.CreateObject("WScr
Set objFSO = CreateObject("Scripting.Fi
x86Path = """C:\Program Files\GIMP-2.0\bin\gimp-co
x64Path = """C:\Program Files (x86)\GIMP-2.0\bin\gimp-co
SetupPath = """\\S3\i$\Gimp\gimp-June 2 11-i686-setup-1.exe"""
TempPath = objWSH.ExpandEnvironmentSt
If objFSO.FileExists(x86Path)
WScript.Quit
Else
objFSO.CopyFile SetupPath, TempPath
objWSH.Run "cmd.exe /C runas /user:mydomain@user /mypassword " & TempPath &_
"\gimp-June 2 11-i686-setup-1.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART"
Ups, of course:
Dim objWSH, objFSO, x86Path, x64Path, SetupPath, TempPath
Set objWSH = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
x86Path = """C:\Program Files\GIMP-2.0\bin\gimp-console-2.6.exe"""
x64Path = """C:\Program Files (x86)\GIMP-2.0\bin\gimp-console-2.6.exe"""
SetupPath = """\\S3\i$\Gimp\gimp-June 2 11-i686-setup-1.exe"""
TempPath = objWSH.ExpandEnvironmentStrings(%temp%)
If objFSO.FileExists(x86Path) or objFSO.FileExists(x64Path) Then
WScript.Quit
Else
objFSO.CopyFile SetupPath, TempPath
objWSH.Run "cmd.exe /C runas /user:mydomain@user /mypassword " & TempPath &_
"\gimp-June 2 11-i686-setup-1.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART"
End If
ASKER
Ok, but I still in the script meets on the last point of my entry:
after installation is complete, delete the installation file from the% TEMP%
The best way that I can think of is to verify the processes are running:
gimp-2.6.11-i686-setup-1.e xe
and
gimp-2.6.11-i686-setup-1.t mp
As long as both processes are running, the script will not (can not) delete the installation files. It occurs to me at the end of the script to add a control loop that processes exist. If processes exist and are currently being created directory either "x86Path" or "x64Path", so must delete the installation file. Otherwise the script in a loop to wait. This is according to this assignment, please be done?
Thank you.
TM
after installation is complete, delete the installation file from the% TEMP%
The best way that I can think of is to verify the processes are running:
gimp-2.6.11-i686-setup-1.e
and
gimp-2.6.11-i686-setup-1.t
As long as both processes are running, the script will not (can not) delete the installation files. It occurs to me at the end of the script to add a control loop that processes exist. If processes exist and are currently being created directory either "x86Path" or "x64Path", so must delete the installation file. Otherwise the script in a loop to wait. This is according to this assignment, please be done?
Thank you.
TM
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I know you asked for a vbscript but why not just use a simple batch file?
If EXIST "C:\Program Files (x86)\GIMP-2.0\bin\gimp-co nsole-2.6. exe" GOTO :EOF
If EXIST "C:\Program Files\GIMP-2.0\bin\ gimp-console-2.6.exe" GOTO :EOF
Copy "\\S3\i$\Gimp\gimp-June 2 11-i686-setup-1.exe" %TMP% /Y
runas /user:mydomain@user /mypassword "%tmp%\gimp-June 2 11-i686-setup-1.exe" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART
If EXIST "C:\Program Files (x86)\GIMP-2.0\bin\gimp-co
If EXIST "C:\Program Files\GIMP-2.0\bin\ gimp-console-2.6.exe" GOTO :EOF
Copy "\\S3\i$\Gimp\gimp-June 2 11-i686-setup-1.exe" %TMP% /Y
runas /user:mydomain@user /mypassword "%tmp%\gimp-June 2 11-i686-setup-1.exe" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART
ASKER
Thanks for the help
TM
TM