Solved

Use VBScript to run an exe located on network

Posted on 2009-07-06
6
784 Views
Last Modified: 2013-12-23
I'm trying to write a very basic VBScript to add to the logon script in AD to remove Groupwise 7 using the utility "cleanit.exe".
The script seems to run without errors but is not executing it on the client/target machine.  Not sure what I'm missing.

Thanks!


Dim WSHShell
Dim sServer, sPath, sSwitches
Dim sServerName, sWinXp, sCmd
Dim Command, objArgs
 
On Error Resume Next
 
Set WSHShell = WScript.CreateObject("WScript.Shell")
 
sServerName = "\\server.path.com"
sPath = "\apps"
sWinXp = "\CleanIt.exe"
sSwitches = " /sn"
 
'Set the command line - format: "\\server\share\path\hotfix.exe" /switches
sCmd = sServerName & sPath & sWinXp & sSwitches
 
Command = sCmd
 
Public Function RunPatch
'set path of executable to command variable
Command = sCmd
'run the command
WSHShell.Run Command,1,False
End Function

Open in new window

0
Comment
Question by:khiggins1979
  • 3
  • 2
6 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 24784721
Hi, khiggins1979.

Comment out the "On Error resume Next" command and see if you get an error.
0
 
LVL 1

Author Comment

by:khiggins1979
ID: 24785280
With "On Error resume Next" still runs with no errors.

Couple things worth mentioning is the share itself is not mapped to a drive letter on the local machines but all users authenticated have access to it.  Not sure if maybe somewhere the script needs to be told to use the current logged in users' authentication?  The only other thing I can think of it is maybe it's trying to run the .exe on a different machine and that the localhost needs to be targeted?

Thanks!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24790473
Does the script run if you run it locally (i.e. double-click on the script instead of attempting to run it via a login script)?
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 1

Author Comment

by:khiggins1979
ID: 24793168
Runs locally without error but doesn't seem to execute the file.  I've checked the processes and wscript, cscript nor the cleanit.exe are there.  Same behavior when ran from the network.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24793389
Purely as a test how about mapping a drive and adjusting the path to the exe to use the mapped drive?
0
 
LVL 13

Accepted Solution

by:
Daz_1234 earned 500 total points
ID: 24924484
Comment out On Error Resume Next, i.e..

'On Error Resume Next
  -(or just delete the line temporarily).

Then change the end run line(s) with the following:

WSHShell.Run Command,1,True
MsgBox "Run Complete"
End Function

Now run it again manually.  Changing the False to True, forces the script to wait until the executable has finished before moving to the next line.  I have added a MsgBox so that you'll know when the call has completed.  Now, if you get no errors, the CleanIt.exe will have run and the problem must be with that exe.  Then you would need to test the exe alone, outside of the script to see why it is not working.

Hope this helps.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Resolve DNS query failed errors for Exchange
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question