Can somebody help me convert this shell script to a normal script?

Set objShell=CreateObject("Wscript.Shell")
objShell.Run "Xcopy \\server\servershare\vpn403i\client\*.* c:\apps21\vpn403i\"

Set objApp = CreateObject("WScript.Shell")
objApp.Run "cmd /C C:\apps21\vpn403i\setup /s"

Thank you very much.
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
What do you mean, convert it to a 'normal' script? It's looks perfectly normal to me, apart from the unnecessary creation of a second shell object [ Set objApp = CreateObject("WScript.Shell") ]
Set objShell=CreateObject("Wscript.Shell")
objShell.Run "Xcopy \\server\servershare\vpn403i\client\*.* c:\apps21\vpn403i\"
objShell.Run "cmd /C C:\apps21\vpn403i\setup /s"


As ever, you may want to add error-trapping, e.g. ensuring that the directory tree 'c:\apps21\vpn403i' exists before proceeding. Always program/script defensively - assume nothing!
Answered 11/21/2008 by: VBScab
Red Belt

Please log in to comment
0
By real VB I guess he means Visual Basic and not VBScript
Answered 11/21/2008 by: AngelD
Red Belt

Please log in to comment
0
...which then begs the question, which version of VB? 3? 5? 6? .Net?

As ever, our psychic powers are required! :)
Answered 11/21/2008 by: VBScab
Red Belt

Please log in to comment
0
I like the term "polish the crystal balls" better though [:D]
Answered 11/21/2008 by: AngelD
Red Belt

Please log in to comment
0
The script I posted works but one of my colleagues mentioned that if I call out a shell and try to deploy it with SMS, there might be problems since its not running under a user context.

I guess he wanted to stay with wmi scripting inside VBScript. Is there a better way to write this script for SMS? Also, sometimes when I run the script, it doesn't do the setup /s just the xcopy.

This is what the SMS engineer had started writing but it didn't work but I think he wants to use just the copyfolder command:

'On Error Resume NExt
Dim objShell, objNewPort, objWMIService, oFSO, Path, strComputerA
Dim RunErrorToReturn, Results
Dim strComputer : strComputer = "."
Dim objNetwork : Set objNetwork = CreateObject("WScript.Network")
strComputerA = objNetwork.ComputerName

Set objWMIService = GetObject("winmgmts:"& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
ProgramFiles = objShell.ExpandEnvironmentStrings("%ProgramFiles%")
windir= objShell.ExpandEnvironmentStrings("%windir%")
temp = objShell.ExpandEnvironmentStrings("%temp%")
allusers=objShell.ExpandEnvironmentStrings("%AllUsersProfile%")

path= oFSO.GetParentFolderName(WScript.ScriptFullName)

'oFSO.CopyFolder "\\server\servershare\VPN403i\client", "c:\apps21\vpn403i\" ,True

'objShell.Run path+"\apps21\vpn403i\setup /s",1,TRUE

Const FOF_CREATEPROGRESSDLG = &H0&
ParentFolder = Path
wscript.echo parentfolder
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(ParentFolder)
objFolder.CopyHere "C:\apps21\vpn403i", FOF_CREATEPROGRESSDLG
Answered 11/21/2008 by: case2k5
Orange Belt

Please log in to comment
0
How do I add error trapping on that script VBScab?

thx
Answered 11/21/2008 by: case2k5
Orange Belt

Please log in to comment
0
ORIGINAL: case2k5
one of my colleagues mentioned that if I call out a shell and try to deploy it with SMS, there might be problems since its not running under a user context.
What we in the UK might refer to as "utter tommy rot." I can't see any reason for that assertion, given what your script's doing.

As for error-trapping, my scripts would look something like this (note the use of the CODE tag - use the '%>' button):
On Error Resume Next
Set objShell=CreateObject("Wscript.Shell")
If Not IsObject(objShell) Then
WScript.Quit
End If
Set objFSO=CreateObject("Scripting.FileSystemObject")
If Not IsObject(objFSO) Then
WScript.Quit
End If

'// The paths could usefully be set with variables to save re-typing.
objShell.Run "Xcopy \\server\servershare\vpn403i\client\*.* c:\apps21\vpn403i\"
If objFSO.FolderExists("c:\apps21\vpn403i") Then
If objFSO.FileExists("c:\apps21\vpn403i\setup.exe") Then
objShell.Run "cmd /C C:\apps21\vpn403i\setup /s"
End If
End If
I think you get the idea which is, essentially, ASSUME NOTHING. Just because creating the shell object always works on your machine (and every machine you tested the script on) doesn't mean it'll work on every machine.

As to not running the setup executable, I think that'll be because the XCOPY hasn't completed. I'll leave that as an exercise for you to work out. Here's a hint http://www.devguru.com/technologies/wsh/17419.asp
Answered 11/23/2008 by: VBScab
Red Belt

Please log in to comment
0
It works after I modified the script like this:

On Error Resume Next
Set objShell=CreateObject("Wscript.Shell")
If Not IsObject(objShell) Then
WScript.Quit
End If
Set objFSO=CreateObject("Scripting.FileSystemObject")
If Not IsObject(objFSO) Then
WScript.Quit
End If

'// The paths could usefully be set with variables to save re-typing.
objShell.Run "Xcopy \\server\servershare\vpn403i\client\*.* c:\apps21\vpn403i\",1,TRUE
If objFSO.FolderExists("c:\apps21\vpn403i") Then
If objFSO.FileExists("c:\apps21\vpn403i\setup.exe") Then
objShell.Run "cmd /C C:\apps21\vpn403i\setup /s",1,TRUE
End If
End If
Answered 11/24/2008 by: case2k5
Orange Belt

Please log in to comment
Answer this question or Comment on this question for clarity