Contractor UK Bulletin Board  PayStream

Go Back   Contractor UK Bulletin Board > Contractor UK Forums > Technical
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 10th November 2008, 14:46   #1
EternalOptimist
Super poster
 
EternalOptimist's Avatar
 
Join Date: Jul 2005
Location: Castle Saburac
Posts: 3,838
Default Active Directory

Active directory question

1. my tentative solution - I need a vb script that will run as a .bat that will create a user profile structure on a machine.



2. the actual problem (in case I am talking balls in 1). There is an msaccess application that produces a file for export. The export is run overnight by a bat file.
If the profiles on the machine have been cleared down, ms office opens a dialogue asking for the user to confirm initials etc. This stops the export bat from running


TIA
__________________
I have decided on my career path. I will become a nun. Sister, please come clean if you wish to avoid a fisting - Jeremy Bender
EternalOptimist is offline   Reply With Quote
Old 10th November 2008, 15:01   #2
spoons
Lurker not a fighter
 
Join Date: Aug 2006
Posts: 72
Default

The profile gets created by the system on logon anyway.

I might have the wrong end of the stick here?
spoons is offline   Reply With Quote
Old 10th November 2008, 15:20   #3
NickFitz
Super poster
 
NickFitz's Avatar
 
Join Date: Jun 2007
Location: Your local branch
Posts: 2,779
Default

Quote:
Originally Posted by EternalOptimist View Post
Active directory question

1. my tentative solution - I need a vb script that will run as a .bat that will create a user profile structure on a machine.



2. the actual problem (in case I am talking balls in 1). There is an msaccess application that produces a file for export. The export is run overnight by a bat file.
If the profiles on the machine have been cleared down, ms office opens a dialogue asking for the user to confirm initials etc. This stops the export bat from running


TIA
Leaving 1 aside (as I don't think that's the right approach) I assume from 2 that you are running your BAT file as a scheduled task?

If so, I think the issue is that, when no user is logged in to the system, the scheduled task will run under the SYSTEM account by default (IIRC). This, I believe, requires the task to run as a service, but Access is an application; I'm not sure if it can run as a service.

In the Task Scheduler, double-click the task to open its property sheet. On the first tab ("Task") there is a "Run as" section towards the bottom. Make sure this has the username of an account that has the necessary privileges for whatever the task has to do, then hit the "Set password" button to... well, to set the password.

The task should then run under that account without problems. If it's still failing (or if all those things are already set), you might need to specify assorted Access command line switches in the BAT file at the point where it's started; the /nostartup one will probably be a good place to start. Then try the /user and /pwd ones, or maybe /profile.
NickFitz is online now   Reply With Quote
Old 10th November 2008, 16:43   #4
EternalOptimist
Super poster
 
EternalOptimist's Avatar
 
Join Date: Jul 2005
Location: Castle Saburac
Posts: 3,838
Default

Quote:
Originally Posted by NickFitz View Post
Leaving 1 aside (as I don't think that's the right approach) I assume from 2 that you are running your BAT file as a scheduled task?

If so, I think the issue is that, when no user is logged in to the system, the scheduled task will run under the SYSTEM account by default (IIRC). This, I believe, requires the task to run as a service, but Access is an application; I'm not sure if it can run as a service.

In the Task Scheduler, double-click the task to open its property sheet. On the first tab ("Task") there is a "Run as" section towards the bottom. Make sure this has the username of an account that has the necessary privileges for whatever the task has to do, then hit the "Set password" button to... well, to set the password.

The task should then run under that account without problems. If it's still failing (or if all those things are already set), you might need to specify assorted Access command line switches in the BAT file at the point where it's started; the /nostartup one will probably be a good place to start. Then try the /user and /pwd ones, or maybe /profile.
thanks nick, I tried all that earlier. The problem is that the user running the app has never run office on this virtual machine, so the MSACCESS/OFFICE welcome screen is coming up to say please confirm your initials etc

I believe at this point it creates the user folders/entries that I am on about, which I called ,erroneously,a user profile. A user would only ever see this screen once, but in the scenario I am describing, they are constantly being allocated to new virtual machines, so they are being promted frequently

sorry for vague factor 10, but I am a dev not an infr



__________________
I have decided on my career path. I will become a nun. Sister, please come clean if you wish to avoid a fisting - Jeremy Bender
EternalOptimist is offline   Reply With Quote
Old 10th November 2008, 16:55   #5
NickFitz
Super poster
 
NickFitz's Avatar
 
Join Date: Jun 2007
Location: Your local branch
Posts: 2,779
Default

Quote:
Originally Posted by EternalOptimist View Post
thanks nick, I tried all that earlier. The problem is that the user running the app has never run office on this virtual machine, so the MSACCESS/OFFICE welcome screen is coming up to say please confirm your initials etc

I believe at this point it creates the user folders/entries that I am on about, which I called ,erroneously,a user profile. A user would only ever see this screen once, but in the scenario I am describing, they are constantly being allocated to new virtual machines, so they are being promted frequently

sorry for vague factor 10, but I am a dev not an infr



There's an MSKB article that might help, although it's full of caveats like "We do not recommend or support Automation to a Microsoft Office application from an unattended user account."
NickFitz is online now   Reply With Quote
Old 10th November 2008, 20:50   #6
lilelvis2000
Contractor Among Contractors
 
lilelvis2000's Avatar
 
Join Date: Jul 2005
Location: the centre of the world - according to Jack Straw
Posts: 1,692
Default

You could try making the entries into the registry.

HKEY_CURREN_USER\Software\Microsoft\Office\Common\ userInfo

Save the contents of a sample user into a .reg file and execute it in your bat file

http://support.microsoft.com/kb/82821

That may work.
lilelvis2000 is offline   Reply With Quote
Old 10th November 2008, 21:23   #7
EternalOptimist
Super poster
 
EternalOptimist's Avatar
 
Join Date: Jul 2005
Location: Castle Saburac
Posts: 3,838
Default

thanks both, I will try these ideas in the a.m.



__________________
I have decided on my career path. I will become a nun. Sister, please come clean if you wish to avoid a fisting - Jeremy Bender
EternalOptimist is offline   Reply With Quote
Old 11th November 2008, 10:10   #8
London75
Lurker not a fighter
 
Join Date: Aug 2008
Location: Manchester
Posts: 76
Default

Add those reg entries (if they're right) into the "Default User" profile on the machine. That way, they'll be used as the default settings for all users on the box.
London75 is offline   Reply With Quote
Old 11th November 2008, 11:23   #9
EternalOptimist
Super poster
 
EternalOptimist's Avatar
 
Join Date: Jul 2005
Location: Castle Saburac
Posts: 3,838
Default

cracked it - simple really

run create object on a virgin machine.
the object picks up the log on as the objects username but without applying it

so , capture it then apply it.


if its not a virgin machine, you are simply capturing the correct username and then applying it back


thanks for all the help dudes



dim objword
dim myUserName
dim myUserInitials
Set objWord = CreateObject("word.Application")
myUserName = objWord.UserName
myUserInitials = objWord.UserInitials
objWord.UserName = myUserName
objWord.UserInitials = myUserInitials
objWord.Quit
__________________
I have decided on my career path. I will become a nun. Sister, please come clean if you wish to avoid a fisting - Jeremy Bender
EternalOptimist is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT. The time now is 05:04.


Advertisers
PayStream

CUK Navigation

Contractor Alliance
Formed a new Ltd Co?

20% off business insurance
£10 off Bauer & Cottrell contract reviews
Find co-workers & client introductions

Increase your value to clients here

Fast Company Formation
Same day online company formation £75 + VAT

Form your Ltd Co Here

Contractor Services


 
Content Relevant URLs by vBSEO 2.4.0 © 2005, Crawlability, Inc.