PDA

View Full Version : VBScript in Vista



smh_2007
07-09-2007, 08:42 AM
Hi To All,

I am trying to run a script that will add users/permissions to Windows\ServiceProfile\NetworkService\AppData\Loca l\Temp. This is because I am using Access with Classic Asp pages in my installation.

Here is the script in it's entirety:

Set WshShell = wscript.CreateObject("Wscript.Shell")
wshShell.Run "icacls %windir%\serviceprofiles\networkservice\AppData\Lo cal\Temp /grant Users:(CI)(S,WD,AD,X)"
wshShell.Run "icacls %windir%\serviceprofiles\networkservice\AppData\Lo cal\Temp /grant ""CREATOR OWNER"":(OI)(CI)(IO)(F)"

This part of the install doesn't seem to be working. The errorcode I get is 1. Can anyone lend some insight into how to get this working.

Thanks,

Sharon

linder
07-09-2007, 08:49 AM
Sharon,

How to you run the above code? Do you "ShellExecute" it as .vbs or something like that?

BTW, why don't you use the "Set Access Control"?

Friedrich

smh_2007
07-09-2007, 08:57 AM
Hi Fredrich,

I just use the Run VBScript command.

Also I'm not familiar with "Set Access Control". Where would I find that.

Sorry for what might seem like simple questions but, I'm a newbie.

Sharon

smh_2007
07-09-2007, 09:09 AM
Hi Freidrich,

Just to let you know, I'm running version 6.0.175 of SetupBuilder.

Thanks,

Sharon

linder
07-09-2007, 09:13 AM
Hi Sharon,

There is an example script in the Example package on how to use VBScripts.

BTW, I would suggest to try the "Set Access Control..." script item.

Friedrich

linder
07-09-2007, 09:14 AM
Sharon,

The Set Access Control function provides support for ACL. An access control list (ACL) specifies the rules for access to a particular resource. Set access control lists on a variety of system objects. Add, edit and remove permissions of files, registry keys, and created folders.

Does this help?

Friedrich

smh_2007
07-09-2007, 09:21 AM
Hi Freidrich,

I did model my install after the example vbscript.sb6. I don't see the Set Access Control function in the Script Functions window. Is it specific to version 6.5? I am running 6.0.175.

Thanks,

Sharon

linder
07-09-2007, 09:22 AM
Sharon,

Sorry, did not notice your version number. We introduced that feature in SetupBuilder 6.5. Click "Check for Updates" to update to the latest version.

Friedrich

linder
07-09-2007, 09:28 AM
Sharon,

What you are trying to do (WScript.Shell) is only available in wshom.ocx (WSHLIB). But "Run VBScript" makes use of msscript.ocx, so your code does not work!

Friedrich

smh_2007
07-09-2007, 09:44 AM
Hi Freidrich,

The script now executes (thank you) but, the permissions were not set. Any thoughts?

Thanks,

Sharon

linder
07-09-2007, 09:49 AM
Sharon,

Sorry, I don't know. I don't have experiences with VBScripts :(

Friedrich

linder
07-09-2007, 09:52 AM
BTW, perhaps "cacls" instead of "icacls" will do the job?

Friedrich

smh_2007
07-09-2007, 10:22 AM
Hi Freidrich,

You mentioned that What I am trying to do (WScript.Shell) is only available in wshom.ocx (WSHLIB). But "Run VBScript" makes use of msscript.ocx, so my code does not work. Is there another scripting function that I should be using. How would I implement WSHLIB?

Thanks,

Sharon

linder
07-09-2007, 10:28 AM
Sharon,

I believe there are some source code examples available on MSDN. What you can do is to compile the code from MSDN into your own DLL and then use that from SetupBuilder.

Or you could try to create a .vbs and then simply execute it via ShellExecute. Of course, this will only work if WSHLIB is available on the machine!

IMO, it's an "overkill" to use WSHLIB to handle access control.

Perhaps this helps:

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cacls.mspx?mfr=true

Does this help?

Friedrich

smh_2007
07-09-2007, 12:46 PM
Hi Freidrich,

If I wanted to run ShellExecute would I do that from the Run Program Script Function. Using ShellExecute as the File Name and the VBS script would be the Start Parameter?

Thanks,

Sharon

linder
07-10-2007, 02:43 AM
Hi Sharon,

If you use the "Run Program..." script function then the .VBS script is the File Name and Target Folder.

Does this help?

Friedrich

smh_2007
07-10-2007, 07:36 AM
Hi Friedrich,

I'm a little confused, sorry.

I need to run these two lines to set the permissions on a Vista machine:

icacls %windir%\serviceprofiles\networkservice\AppData\Lo cal\Temp /grant Users:(CI)(S,WD,AD,X)

icacls %windir%\serviceprofiles\networkservice\AppData\Lo cal\Temp /grant "CREATOR OWNER":(OI)(CI)(IO)(F)

I'm not sure how to do that. I was thinking that in my script file I could say something like this:

Set objShell = CreateObject("Shell.Application")
strApplication="ICACLS"
strArguments="Windows\serviceprofiles\networkservice\AppData\Loc al\Temp /grant Users:(CI)(S,WD,AD,X)"
objShell.ShellExecute strApplication, strArguments, "", "runas"

Then I could use the Run VBScript function.

What do you think?

Thanks for all your patience, I sincerely appreciate it.

Sharon

linder
07-10-2007, 07:52 AM
Sharon,

Hmm, I just compiled the VBScript demo script for SetupBuilder 6.5 and it does not work. Item in review.

Friedrich

linder
07-10-2007, 08:05 AM
Sharon,

Could you please send your email address to support (at) lindersoft (dot) com. There was a bug in the VBScript processing component. Under certain circumstances, it did not detect the correct VBScript file size.

We'll send you an internal new VBScript component. This works fine with the VBScript demo project. Perhaps this will also solve your problem.

Friedrich

smh_2007
07-10-2007, 12:08 PM
Hi Friedrich,

I wanted to let you know that I had some success today in setting the permissions for USERS and CREATOR OWNER on a Vista machine.

I created a script with the following code:

Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "ICACLS.EXE", "C:\Windows\ServiceProfiles\NetworkService\AppData\ Local\Temp /grant USERS:(CI)(S,WD,AD,X)", , ,"runas"
objShell.ShellExecute "ICACLS.EXE", "C:\Windows\ServiceProfiles\NetworkService\AppData\ Local\Temp /grant ""CREATOR OWNER"":(OI)(CI)(IO)(F)", , ,"runas"

I then used the Set Access Control function as follows:

Access Control:Grant File Access "%TMPDIR%\VISTATEST.VBS"

It seems to work, at least on my machine. I have Virtual PC installed so I'll try it there as well.

There's a lot more work to do in my install but, I feel good about getting over this hurdle.

Thanks for all your help,

Sharon

linder
07-11-2007, 03:09 AM
Sharon,

Perfect! Thank you for the good news :)

Friedrich