bizcuts
(Fresh Scripter)
2006-07-18 05:00 PM
trying to create a profile path with %osver%

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


Richard H.Administrator
(KiX Supporter)
2006-07-18 05:19 PM
Re: trying to create a profile path with %osver%

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.


bizcuts
(Fresh Scripter)
2006-07-18 06:29 PM
Re: trying to create a profile path with %osver%

im on it

will update!!!!!!

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


bizcuts
(Fresh Scripter)
2006-07-19 04:17 PM
Re: trying to create a profile path with %osver%

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!.


Arend_
(MM club member)
2006-07-19 04:58 PM
Re: trying to create a profile path with %osver%

Could you post your script so we can actually see what's happening ?

NTDOCAdministrator
(KiX Master)
2006-07-19 07:38 PM
Re: trying to create a profile path with %osver%

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.


bizcuts
(Fresh Scripter)
2006-07-20 06:05 PM
Re: trying to create a profile path with %osver%

ok

here goes nothing!!!!!


Les
(KiX Master)
2006-07-20 06:49 PM
Re: trying to create a profile path with %osver%

Quote:

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



I guess he missed that part.


bizcuts
(Fresh Scripter)
2006-07-20 07:04 PM
Re: trying to create a profile path with %osver%

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"


Mart
(KiX Supporter)
2006-07-20 07:18 PM
Re: trying to create a profile path with %osver%

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


bizcuts
(Fresh Scripter)
2006-07-20 07:51 PM
Re: trying to create a profile path with %osver%

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


NTDOCAdministrator
(KiX Master)
2006-07-20 08:55 PM
Re: trying to create a profile path with %osver%

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.



LonkeroAdministrator
(KiX Master Guru)
2006-07-20 11:34 PM
Re: trying to create a profile path with %osver%

what is this:
Code:

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


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

set "OSVER="



Richard H.Administrator
(KiX Supporter)
2006-07-21 09:17 AM
Re: trying to create a profile path with %osver%

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.


bizcuts
(Fresh Scripter)
2006-07-21 04:26 PM
Re: trying to create a profile path with %osver%

"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!


Les
(KiX Master)
2006-07-21 04:49 PM
Re: trying to create a profile path with %osver%

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.


Richard H.Administrator
(KiX Supporter)
2006-07-21 04:56 PM
Re: trying to create a profile path with %osver%

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.


bizcuts
(Fresh Scripter)
2006-07-21 05:02 PM
Re: trying to create a profile path with %osver%

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"


bizcuts
(Fresh Scripter)
2006-07-21 05:07 PM
Re: trying to create a profile path with %osver%

Richard H.

i will try that. and thanx

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