Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

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-console-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:
runas /user:mydomain@user /mypassword %TMP%\gimp-June 2 11-i686-setup-1.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART

Open in new window

- Finally, after installing the script delete the exe file from the Windows temporary folder.

Thank you in advance for any help.
TM













0
Thomas_Meyer
Asked:
Thomas_Meyer
  • 4
  • 4
1 Solution
 
X_layerCommented:
Ok let's see if I understand. If "gimp-console-2.6.exe" process is running, must be stopped first?
0
 
Thomas_MeyerAuthor Commented:
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.
0
 
X_layerCommented:
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"

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Thomas_MeyerAuthor Commented:
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("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"
0
 
X_layerCommented:
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

Open in new window

0
 
Thomas_MeyerAuthor Commented:
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.exe
and
gimp-2.6.11-i686-setup-1.tmp

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
0
 
X_layerCommented:
Ok sorry, i've forrgot to do that. Here you go:
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", 0, true
	objFSO.DeleteFile TempPath & "\gimp-June 2 11-i686-setup-1.exe"
End If

Open in new window

0
 
tighecCommented:
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-console-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
0
 
Thomas_MeyerAuthor Commented:
Thanks for the help
 TM
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now