Solved

Use VBScript to run an exe located on network

Posted on 2009-07-06
6
805 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
Suggested Courses
Course of the Month4 days, 17 hours left to enroll

636 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