Sign in to follow this  
Followers 0
ken82m

Win2k Long Run Command Won't Run within RunAs

7 posts in this topic

#1 ·  Posted (edited)

I have a script which I've been using and worked perfectly. Now I have to get it working within a RunAsSet and the command fails on Windows 2000.

I get an AutoIt error on the RunWait command saying "Parameter is incorrect" the same script is fine in Windows XP. Anyone have any idea or a work around?

Code:

$TempDir = @TempDir

RunAsSet(xxxxx,xxxxx,xxxxx)

RunWait($TempDir & "\dsmove.exe " & $DSMOVE & " -newparent " & '"OU=SAP,OU=Computers,OU=Peachtree City,OU=Locations,OU=United States,DC=CWD,DC=NAM,DC=CI,DC=ROOT"', $TempDir)

RunAsSet()

The actual command would look like this:

dsmove.exe "CN=KennyUser-2KL,OU=Computers,OU=Peachtree City,OU=Locations,OU=United States,DC=CWD,DC=NAM,DC=CI,DC=ROOT" -newparent "OU=SAP,OU=Computers,OU=Peachtree City,OU=Locations,OU=United States,DC=CWD,DC=NAM,DC=CI,DC=ROOT"

Yes I know that's one long a** command lol Perhaps this is some sort of limitation in 2000. Like I said this same command is fine on Win2K and XP without a RunAs.

And still works on XP with a RunAs.

But 2K this command and a RunAs don't mix ;)

Thanks,

Kenny

Edited by ken82m

My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites



RunWait(RunWait($TempDir & "\dsmove.exe " & $DSMOVE & " -newparent " & '"OU=SAP,OU=Computers,OU=Peachtree City,OU=Locations,OU=United States,DC=CWD,DC=NAM,DC=CI,DC=ROOT"', $TempDir)

Did you notice you have two RunWait()'s?

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Sorry that was just a typo I started to type it manually and then pasted the command.

Post corrected.


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites

OK, I confirmed this behavior in Win2K. There does appear to be a character limit we're running into.

I'll run some tests to find out what this limit is and submit a bug report.

Meanwhile, here are a couple of suggestions:

1) Don't use RunAsSet(), but use the -u and -p parameters of DSMove.exe.

2) Compile the procedures into a separate EXE and launch it using RunAsSet(). I've used this method extensively with large scripts and have not encountered any issues.

p.s. Be careful using user variables in conjunction with RunAsSet().

My RunAsSet test user doesn't have access to @TempDir (My Temp Dir)


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

okay I'll try that

Thanks for the tip and the research, I know what you're talking about with the temp dir. I'm designing this for domain users to run, the runas will be a domain admin account so it will have full control of the users temp directory by default.

I thought I was going crazy when this started I kept checking my code even though it looked fine.

Thanks again you guys always have the answer!

Kenny ;)


My Contributions _StringMultiReplace PC Builders Console - Secure PDF Creator - Cisco VPN Installer MS DNS Server Backup Script - MS DHCP Backup Script IT Admin Console - Toggle Admin Mode - MyMovies-Add Discs Script - IT Help Desk and System Information Tool - Set On Lid Close Power Option - Streaming Media Server & Website "I believe that when we leave a place, part of it goes with us and part of us remains... Go anywhere, when it is quiet, and just listen.. After a while, you will hear the echoes of all our conversations, every thought and word we've exchanged.... Long after we are gone our voices will linger in these walls for as long as this place remains."

Share this post


Link to post
Share on other sites

Just some general observations...

In cases like this I'll build the command line as a string and then pop open a MsgBox immediately before the call to Run[Wait] to see what it's going to look like.

I also keep a compiled script that just opens a MsgBox showing $CMDLINERAW (the raw command line it was called with), I'd rename it to DSMOVE.EXE and put it in the TEMP folder in this case and run the script to see what DSMOVE was being fed...


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

@ DaveF:

Those are good observations, and good debugging practices.

I also keep such a dummy exe around for testing.

Since the end result is a console app, I just made CMD echo the commandline.

That way DSMove isn't executed and I can see the parameters as recognized by CMD.

This is the code I used to test:

$TempDir = @TempDir
  $DSMOVE = '"CN=KennyUser-2KL,OU=Computers,OU=Peachtree City,OU=Locations,OU=United States,DC=CWD,DC=NAM,DC=CI,DC=ROOT"'
  RunAsSet("user", @ComputerName, "password")
 $RunCommand = $TempDir & "\dsmove.exe " & $DSMOVE & " -newparent " & 'OU=SAP,OU=Computers,OU=Peachtree City,OU=Locations,OU=United States,DC=CWD,DC=NAM,DC=CI,DC=ROOT'
  RunWait(@ComSpec & " /k echo " & $RunCommand, $TempDir)
  RunAsSet()
If you comment out only the RunAsSet() lines, it will succeed, with the parameters passed properly.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0