Page 1 of 1 1
Topic Options
#188254 - 2008-06-17 09:13 PM Copy directory using runnas
steeb Offline
Just in Town

Registered: 2008-04-18
Posts: 3
Hello, currently I use a logon script (scriptstart) that is based off of kixtart.

I want to execute commands to copy files, and make directories, but the script wont run because the user doesnt have local access. I am trying to use the runnas utility. I have placed it in \\server\netlogon\Scriptstart\custom\runnas.exe

The following command executes fine on machines where local admin has rights, but not any average domain users.

Please advise

 Code:
if not exist "c:\Documents and Settings\%username%\Spark\spark.properties" goto :usermd else :dumd

:usermd

md "c:\Documents and Settings\%username%\Spark"

copy "\\exchangeserver\netlogon\spark\spark.properties" "%userprofile%\Spark\"


if not exist "c:\Documents and Settings\Default User\Spark\spark.properties" goto :dumd

:dumd

md "c:\Documents and Settings\Default User\Spark"

copy "\\exchangeserver\netlogon\Spark\spark.properties" "C:\Documents and Settings\Default User\Spark\*.*

if not exist "c:\windows\krb5.ini" goto :krb

:krb

copy "\\exchangeserver\netlogon\Spark\krb5.ini" "C:\windows\krb5.ini

Top
#188255 - 2008-06-17 10:08 PM Re: Copy directory using runnas [Re: steeb]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
First off let me begin by saying that the use of GOTO is frowned upon anymore. Makes for very hard to follow code.

Second, you have no ENDIF to go with your IF

Third, why are you changing the Default user location? This should be a part of any build that you are using and not handled in the logon script. As the only time that Default user is used is upon the first logon of a user.

Below is your code cleaned up a small amount that will resolve some of your issues. As to copying the krb5.ini to the System folder, you have several options one of them being to use RUNNAS.

 Code:
if not exist "c:\Documents and Settings\%username%\Spark\spark.properties" 
	md "c:\Documents and Settings\%username%\Spark"
	copy "\\exchangeserver\netlogon\spark\spark.properties" "%userprofile%\Spark\"
EndIf


if not exist "c:\windows\krb5.ini" 

	copy "\\exchangeserver\netlogon\Spark\krb5.ini" "C:\windows\krb5.ini

EndIf


Since you are checking for the spark folder for each user as they logon, there is no need for the Default User to have it.

I did not address the way to copy the file to the system folder as you have to decide the way you want to handle it before we can say exactly the way to do it.
_________________________
Today is the tomorrow you worried about yesterday.

Top
#188256 - 2008-06-18 01:03 AM Re: Copy directory using runnas [Re: Gargoyle]
steeb Offline
Just in Town

Registered: 2008-04-18
Posts: 3
Gargoyle, thanks for the prompt response and clarification. Don't know why I put the default profile. It may have been there from something else I was testing, but found a better solution.

I would more than likely use the Runnas command. What would be the format to execute to write to the windows directory

Top
#188257 - 2008-06-18 02:02 AM Re: Copy directory using runnas [Re: steeb]
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
I have never used the RUNNAS as provided by Shawn.

There are many others here that can chime in and help with that.
_________________________
Today is the tomorrow you worried about yesterday.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 146 anonymous users online.
Newest Members
nremmel, AlexTheGreat, ovdmtz, AlexPallaress, wschenk
17490 Registered Users

Generated in 0.031 seconds in which 0.012 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org