Solved

Use VBScript to run an exe located on network

Posted on 2009-07-06
6
768 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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 12

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Binding MAC To Active Directory Domain 1 21
Powershell script update 2 30
Windows server 2008 5 33
exchange, active directory 5 16
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now