Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy,Run,Delete Program from network in VBScript

Status
Not open for further replies.

Zeiram

IS-IT--Management
Joined
Apr 28, 2010
Messages
1
Location
US
Hello,

I'm hoping someone can help me accomplish my goal - I want to create a vbs script to be run in group policy that copies a folder to the local machine, executes the program, allows enough time for the program to do it's thing, and then deletes it.

Can someone with more than my non-existent grasp of vbscript look what I have over and see if it'll work?

Perhaps best practice would be to chop it up into multiple scripts?

Piecing together various parts, I've created this Frankenstein of a vbscript:

Set FSO =CreateObject("scripting.FileSystemObject")
FSO.CopyFolder "\\SERVER\share", "c:\temp" ,True
MsgBox"BackUp completed, Goodbye", vbInformation, "Script Informer"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """C:\Temp\program.exe""",0,true

Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
wscript.Sleep 30

dim filesys, demofolder
set filesys = CreateObject ("Scripting.FileSystemObject")
set demofolder = filesys.GetFolder("c:\temp\share")
demofolder.Delete


Thanks much,

-Drew
 
copy and delete is straight forward, executing it on the PC I have no idea how you going to do that but I can help on the wait for program to finish.

Call somefile


Function somefile
Set oExec = WshShell.Exec(("T:\Software\Install\setup.exe /s"))
' wait until finished
Do While oExec.Status <> 1
WScript.Sleep 100
Loop
End Function

MCITP:EA/SA, MCSE, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top