Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to run a vbscript passing parameters to a perl script in the background?

Posted on 2004-11-12
9
Medium Priority
?
368 Views
Last Modified: 2008-01-09
Hi,
I have a over 6000 systems that are heavily locked down.  I distribute software to these systems, however the software distribution agent on these systems just up and dies.  In order to fix the agent, I have to remote control the system, reboot in admin mode (they are W2K systems), stop a service, delete files, modify a file, telnet and remove the name from a database, then start the service.

I have written a perl script that successful does all of the above steps.  However I can't run the perl script as the locked down user - permission denied.  I found this nifty vbscript that launches the runas and allows me to pass administrative priveledges to the perl script.  It works great... however I need this to run in the background and not disturb the associate working on the system.  I'm assuming my problem is within the vbscript, below is the code:
---------------------------------------------------------------------------------
On Error Resume Next
dim WshShell,FSO

'change these to the apropriate values.  Make sure that the double quotes remain.
sUser="admin"
sPass="adminpassword"&VBCRLF
sCmd="c:\program files\perl\bin\perl c:\fixagent.pl"

set WshShell = CreateObject("WScript.Shell")
set WshEnv = WshShell.Environment("Process")
WinPath = WshEnv("SystemRoot")&"\System32\runas.exe"
set FSO = CreateObject("Scripting.FileSystemObject")

rc=WshShell.Run("runas /env /user:" & sUser & " " & CHR(34) & sCmd & CHR(34), 2, FALSE)
'run a tight loop until the command window comes up
While wshShell.AppActivate(WinPath) = False
Wend
WshShell.SendKeys sPass 'send the password to the waiting window.

set WshShell=Nothing
set WshEnv=Nothing
set FSO=Nothing

wscript.quit
-----------------------------------------------------------------------------------------------

If it's helpful, let me know if you would like the perl script.

I would really like to get this working as soon as possible.  Any idea on how to get this to run in the background?  I can use a hero ;)

Thanks,
Tilly
0
Comment
Question by:CComberg
  • 4
  • 3
8 Comments
 
LVL 9

Expert Comment

by:Dang123
ID: 12569742
Tilly,
    .SendKeys works with the window that has focus, I dont think you can run this in the background. Does the script take long to run? Do you have telnet access to the computers or how are you taking remote control of the machines?
Dang123
0
 
LVL 9

Expert Comment

by:Dang123
ID: 12569764

    Oops, I thought one thing and typed another, I ment to ask if you have terminal services access to the machines   : /
0
 

Author Comment

by:CComberg
ID: 12569959
The script may or may not take long to run.  After the vbscript passes the runas and launches the perl script, the perl script will look at a log file and see if login was successful, if it doesn't find that it was successful then the script will take about 5 - 8 minutes to run.  If it was successful then it will only take a few seconds to run.

I won't be running this program remotely - what I will end up doing is distributing the script to all 6000+ systems and setting up a job on all the systems (using the 'at' command) to run the script at noon.  Basically like each system is standalone.

Any ideas outside of vbscript to get the perl script to execute in the background as an administrative user versus the locked down user that doesn't have permissions?

Thanks,
Tilly
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Expert Comment

by:Dang123
ID: 12570019
Tilly,
    Sorry, the only other thing I can think of is to tell everyone to leave the machine on overnight and schedule it for off-hours (midnight) insted if noon.

Good luck

Dang123
0
 

Author Comment

by:CComberg
ID: 12570243
The issue with running it at night is that's when I typically do my distributions and if the agent is broken, I want it fixed before I do the distribution or the distribution will fail.  I've tried the at command and not using interactive but it doesn't seem to kick off my application :-/

If you think of anything let me know - I'm not opposed on trying another method or language :)

Thanks,
Tilly
0
 

Author Comment

by:CComberg
ID: 12570861
I've answered my own question - kewl!!  the answer is CPAU developed by Joe Richards and can be found at www.joeware.net.  It is much nicer than the vbscript and has several switches that were useful for me like the -hide switch and the ability to encode the file.

Tilly
0
 
LVL 9

Expert Comment

by:Dang123
ID: 12583500
modulo,
    I have no objections to PAQing the question with a refund.

Tilly,
    Glad you found your answer, and thanks for sharing!

Dang123
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12585055
PAQ-ing the question and refunding 500  points

Thanks Dang123 !

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

580 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