In a followup on this topic, i ran into some issues.. I found out that cacls is the way to go about when settings rights on files locally. Unfortunately, SMS 2003 seems top be unable to distribute using CMD's, so i'm going about using a VBS. This is what i have so far:


Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")

On Error Resume Next

WSHShell.Run"C:\WINDOWS\System32\cacls.exe C:\Program Files\Windows Media Player\wmplayer.exe /E /P USERS:n", 1,true
WSHShell.Run"C:\WINDOWS\System32\cacls.exe C:\Program Files\Windows Media Player\wmplayer.exe /E /P POWER USERS:n", 1, true
Wscript.Quit(0)


Only problem is, when using cacls, the path (or file) must be between quotes. ("") That doesn't work with the VB script.. The WSHShell.Run need to be between quotes. Any way around this? I could try to use variables, but i'm still a newbie to VB so any help would be greatly appreciated.. Thanks!
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
I gave up on using the shell with command lines. I'm sure there is some syntax guru out there that can figure it out. I actually use WMI for this kind of stuff because I think it's easier and once you start learning it there really is a lot more you can do. Try the code below and see if that works:


Option Explicit
Dim objWMIService, objProcess, objCalc
Dim strShell, objProgram, strComputer, strExe

strComputer = "."
strExe = "cacls.exe" & " " & "C:\Program Files\Windows Media Player\wmplayer.exe /E /P USERS:n"
' Connect to WMI
set objWMIService = getobject("winmgmts://"_
& strComputer & "/root/cimv2")

' Obtain the Win32_Process class of object.
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe

'Execute the program now at the command line.
Set strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)

'WScript.echo "Created: " & strExe & " on " & strComputer
WSCript.Quit

Just duplicate it for the second cacls command you want to use.

Hope that helps.
Answered 01/11/2006 by: yarborg
Blue Belt

Please log in to comment
0
Unfortunately, still no go.. The script runs ok, but Cacls is giving me problems.. The problem is in the command. Should read:

C:\WINDOWS\System32\cacls.exe "C:\Program Files\Windows Media Player\wmplayer.exe" /E /P USERS:n

VB doesn't seem to like the quotes around the path.. But they need to be there, or else the calcs command doesn't work. [:(] (Did I say "Thank you Microsoft! today?") So i'm basically stuck with the same issue as before.
Thanks for your help though, i'm going to look into WMI, cause that seems to open up a lot more possibilities.. Maybe you have some other suggestions regarding my "problem"? Thanks!
Answered 01/12/2006 by: neo2000
Purple Belt

Please log in to comment
0
Ok here is the correct syntax to accomplish this. Seems to work with notepad.exe. Basically it is the Chr(34) character reference that we needed.

Option Explicit
Dim objWMIService, objProcess, objCalc
Dim strShell, objProgram, strComputer, strExe

strComputer = "."
strExe = "C:\WINDOWS\System32\cacls.exe" & " " & Chr(34) & "C:\Program Files\Windows Media Player\wmplayer.exe" & Chr(34) & " /E /P USERS:n"
' Connect to WMI
set objWMIService = getobject("winmgmts://"_
& strComputer & "/root/cimv2")

' Obtain the Win32_Process class of object.
Set objProcess = objWMIService.Get("Win32_Process")
Set objProgram = objProcess.Methods_( _
"Create").InParameters.SpawnInstance_
objProgram.CommandLine = strExe

'Execute the program now at the command line.
Set strShell = objWMIService.ExecMethod( _
"Win32_Process", "Create", objProgram)

WScript.echo "Created: " & strExe & " on " & strComputer
WSCript.Quit

I left the echo in there so you could see the quotes in the strExe.
Answered 01/12/2006 by: yarborg
Blue Belt

Please log in to comment
0
That seems to work! [:D] Thank you for all the help! [;)]
Answered 01/12/2006 by: neo2000
Purple Belt

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