Page 1 of 1 1
Topic Options
#164598 - 2006-07-18 05:00 PM trying to create a profile path with %osver%
bizcuts Offline
Fresh Scripter

Registered: 2006-07-04
Posts: 10
im a kix n00by...well in all honesty im a complete scripting noob!
but i have managed to make an account creation script...which is very cool (IMO)
but lacks 1 major thing........in my profile path within A.D. i need to have it as so \\servername\profiles%osver%\userid
i use dsmod/dsmove in my script
i need to push the %osver% command in as is, but it keeps resolving to \\servername\profilesXP\userid
how can i get my script to keep it as %osver%?

i have tried double % to no avail.

any feedback on this would be a bonus! cheers

Top
#164599 - 2006-07-18 05:19 PM Re: trying to create a profile path with %osver%
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You must have an environment variable %OSVER% set somewhere.

If you have, you will need to escape it both in KiXtart by specifying it as %%OSVER%%, and if you are passing it to an external command you may need to escape it again!

It's a bit trial and error, but a couple of things you could try are:
  1. Don't use "%COMSPEC%" or "cmd" to run the commands - this will disable the command line interpreter behaviour.
  2. Specify the path as "^%%PATH^%%" with should disable the "%" metacharacter for both KiXtart and the external commands.
  3. Reset the %OSVER% environment variable so that it doesn't cause you problems.
  4. Avoid putting probelematical characters in your paths.


Personally I'd go for the last option.

Top
#164600 - 2006-07-18 06:29 PM Re: trying to create a profile path with %osver%
bizcuts Offline
Fresh Scripter

Registered: 2006-07-04
Posts: 10
im on it

will update!!!!!!

the 4th option is not an option (i have a requirement to meet :/ )

Top
#164601 - 2006-07-19 04:17 PM Re: trying to create a profile path with %osver%
bizcuts Offline
Fresh Scripter

Registered: 2006-07-04
Posts: 10
ok
i have tried %%osver%% %%%osver%%% and ^%%osver^%%
my script also disables the "set=%osver%"
but still it resolves it to "profilesXP" my colleague seems to think i will need to learn about "adsi"......i think need to learn kix 1st!.

Top
#164602 - 2006-07-19 04:58 PM Re: trying to create a profile path with %osver%
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Could you post your script so we can actually see what's happening ?
Top
#164603 - 2006-07-19 07:38 PM Re: trying to create a profile path with %osver%
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well it must be something in how you're coding it as I get the following.

Code:
'ver is: ' + %%OSVER%% ?  



Returns the following for me on the console.

ver is: %OSVER%

Please post your code within CODE TAGS so we can see what you're doing.

Top
#164604 - 2006-07-20 06:05 PM Re: trying to create a profile path with %osver%
bizcuts Offline
Fresh Scripter

Registered: 2006-07-04
Posts: 10
ok

here goes nothing!!!!!


Edited by bizcuts (2006-07-21 04:19 PM)

Top
#164605 - 2006-07-20 06:49 PM Re: trying to create a profile path with %osver%
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

Please post your code within CODE TAGS so we can see what you're doing.



I guess he missed that part.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#164606 - 2006-07-20 07:04 PM Re: trying to create a profile path with %osver%
bizcuts Offline
Fresh Scripter

Registered: 2006-07-04
Posts: 10
tags......i ware one

did u not see how i started this thread "NOOBY"

thats the operative word here!

so if you could be so kind to bare with my noobish behaviour i will endevour to get it right.

tell me the definition of a "TAG"

Top
#164607 - 2006-07-20 07:18 PM Re: trying to create a profile path with %osver%
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4672
Loc: The Netherlands
When making a new reply there is a link called code below the textbox you type the post in.
These code tags will preserve the formatting of the stuff you post so it is much easier to read.
If you put code in between the square brackets above your script and /code in between square brackets below our script it be much more readable.

Like this:

Code:

Break on

If $somestuff = $someotherstuff
?"Yeeehaaaa!! We have a winner!"
Else
?"Sorry somestuff and someotherstuff do not match."
EndIf



You see how the formatting gets preserved so the flow of the script is easy to follow?
Maybe you could edit the post and put the code tags around the code.

Don’t worry, we all had to learn once


Edited by Mart (2006-07-20 07:19 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#164608 - 2006-07-20 07:51 PM Re: trying to create a profile path with %osver%
bizcuts Offline
Fresh Scripter

Registered: 2006-07-04
Posts: 10
cheers mart

im a noob but i listen and absorbe and learn!!

sooooooooooooooooo, back to the issue in hand.

can you guys spot what im doing wrong?

i am baffled as is my mentor

Top
#164609 - 2006-07-20 08:55 PM Re: trying to create a profile path with %osver%
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Okay Mart was too quick for me on that one, but I'll post anyways.

However another issue is the LONG LINES
You need to edit and break the long lines - the whole point
is that if your post is TOO difficult to read then most
people just won't take the time as we all have plenty of
things to do in our daily work lives already.

So now that you know how to EDIT and use CODE TAGS,
please go back and edit again and this time break the
long lines so that a normal 1024x768 monitor won't need
to scroll to read your post.

Thanks.


Top
#164610 - 2006-07-20 11:34 PM Re: trying to create a profile path with %osver%
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
what is this:
Code:

$rc="%comspec% /e:1024 /c set OSVER="
Shell $rc


wouldn't it be easier to just do:
Code:

set "OSVER="


Top
#164611 - 2006-07-21 09:17 AM Re: trying to create a profile path with %osver%
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Ok, I'm confused.

Why are you creating roaming profile directories? This is done automatically by Windows when you log off.

You also appear to be creating three romaing profile directories with slightly different paths.

Because you are using the environment variable in DOS intepreter commands you must escape the % characters at the point that you execute the DOS command.

The easiest thing to do is to find out why you are manually creating roaming profile directories and fix that.

Top
#164612 - 2006-07-21 04:26 PM Re: trying to create a profile path with %osver%
bizcuts Offline
Fresh Scripter

Registered: 2006-07-04
Posts: 10
"Ok, I'm confused.

Why are you creating roaming profile directories? This is done automatically by Windows when you log off."

this i dont care about.

all i need to suss is the %osver% bit, n the jobs a good un!

if i need to rem out the roaming profiles xp\roaming profiles later...thats fine.

dont loose focus on the issue in hand!

Top
#164613 - 2006-07-21 04:49 PM Re: trying to create a profile path with %osver%
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I don't know why you spawn a new child (shell) CMD to set OSVER=. Do changes to the child ever get back to the parent? AFAIK the child will inherit from the parent but the parent would not update from the child.

You didn't have to post ALL your code and open it up to scrutiny but you could at least post the relevant portion so we can see what you are doing. I see you don't take critisism well and deleted all your code. Your choice.

Top
#164614 - 2006-07-21 04:56 PM Re: trying to create a profile path with %osver%
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

"Ok, I'm confused.

Why are you creating roaming profile directories? This is done automatically by Windows when you log off."

this i dont care about.

all i need to suss is the %osver% bit, n the jobs a good un!

if i need to rem out the roaming profiles xp\roaming profiles later...thats fine.

dont loose focus on the issue in hand!




Uhm... this is the issue in hand.

You have a problem because you are trying to create a directory with a path name containing metacharacters. You are going to struggle to get it working because DOS is interpreting them. It's not impossible to get working, just a bit tricky.

Bearing in mind that there is rarely a good reason to create these directories in the first place, it is far simpler just to not create them and let Windows handle it instead.

If you really insist on creating them manually, you could try doing something like this:
Code:

$sPath="\\server\d$\path%%OSVER%%\"+$sUserID
$iResult='"'+%COMSPEC%+'" /C SET %%OSVER%%= && SomeCommand "+$sPATH+" SomeOptions"



This bit of trickery clears the OSVER variable and runs the command in the same instance of the interpreter.

Top
#164615 - 2006-07-21 05:02 PM Re: trying to create a profile path with %osver%
bizcuts Offline
Fresh Scripter

Registered: 2006-07-04
Posts: 10
Not true.

I realised that i was exposing data I shouldn’t

I will re post it once i have edited it

I am here to learn

As I said, I am new to all this. I only have one request, yet people are going off on a tangent......

If other things in my script seem odd, That’s fine. We could discuss this later after I have resolved the "current issue"

Top
#164616 - 2006-07-21 05:07 PM Re: trying to create a profile path with %osver%
bizcuts Offline
Fresh Scripter

Registered: 2006-07-04
Posts: 10
Richard H.

i will try that. and thanx

i dont have time today to mess with my script but i will update monday.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.072 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

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