Solved

Use VBScript to run an exe located on network

Posted on 2009-07-06
6
790 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

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

Suggested Solutions

Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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.

789 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