NaasMarais
(Fresh Scripter)
2009-10-30 09:01 AM
error in runnas script

Hi,

I have this problem with the line i need to run
 Code:
SHELL '%comspec% /c %systemroot%\system32\runnas.exe /user:rds\xxxxx "%logonserver%\netlogon\bginfo\bginfo.exe %logonserver%\netlogon\bginfo\rds.bgi /nolicprompt /silent /timer:0" /password:xxxx /env'
 

It tells me "The system cannot find the file specified"
When I copy and paste this into cmd it work no probs
 Code:
%systemroot%\system32\runnas.exe /user:rds\xxxxx "%logonserver%\netlogon\bginfo\bginfo.exe %logonserver%\netlogon\bginfo\rds.bgi /nolicprompt /silent /timer:0" /password:xxxx /env


Please can someone point out my problem for me must be something to do with the %COMSPEC%

Thanks


Richard H.Administrator
(KiX Supporter)
2009-10-30 09:43 AM
Re: error in runnas script

Make sure that your current working drive and directory are real as some processes will object if they are not, and they may not be during login / runas activities.

Output the value of the command so that you can check it - the event log is a handy place to write it if your script runs hidden:
 Code:
GO "C:"
CD "C:\"

$sCommand='"'+%COMSPEC%
	+'" /c "'+%SYSTEMROOT%+'\system32\runnas.exe" /user:rds\xxxxx "'
	+%LOGONSERVER%+'\netlogon\bginfo\bginfo.exe" "'
	+%LOGONSERVER%+'\netlogon\bginfo\rds.bgi" /nolicprompt /silent /timer:0 /password:xxxx /env'
 
$=LogEvent(4,0,"About to execute: "+$sCommand,"","MyScript.kix")
Shell($sCommand)


NaasMarais
(Fresh Scripter)
2009-10-30 09:54 AM
Re: error in runnas script

Hi Richard

I ran the script you did and got this back from the event log


The description for Event ID ( 0 ) in Source ( MyScript.kix ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: About to execute: "C:\WINDOWS\system32\cmd.exe" /c "C:\WINDOWS\system32\runnas.exe" /user:rds\xxxxx "\\RDSJNBPEN2\netlogon\bginfo\bginfo.exe" "\\RDSJNBPEN2\netlogon\bginfo\rds.bgi" /nolicprompt /silent /timer:0 /password:xxxx /env.


NaasMarais
(Fresh Scripter)
2009-10-30 10:04 AM
Re: error in runnas script

Sorry forgot to enter the username and password

The description for Event ID ( 0 ) in Source ( MyScript.kix ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: About to execute: 0.


Richard H.Administrator
(KiX Supporter)
2009-10-30 10:06 AM
Re: error in runnas script

 Quote:
"C:\WINDOWS\system32\cmd.exe" /c "C:\WINDOWS\system32\runnas.exe" /user:rds\xxxxx "\\RDSJNBPEN2\netlogon\bginfo\bginfo.exe" "\\RDSJNBPEN2\netlogon\bginfo\rds.bgi" /nolicprompt /silent /timer:0 /password:xxxx /env


Ok, so you can see that all you environment variables have expanded, so your %COMSPEC% is fine.

Check that the other values/paths are correct, and if they are you are going to need to start breaking the process down to find which bit is failing.


NaasMarais
(Fresh Scripter)
2009-10-30 10:08 AM
Re: error in runnas script

Ok let me try that

Richard H.Administrator
(KiX Supporter)
2009-10-30 10:09 AM
Re: error in runnas script

 Quote:
About to execute: 0


I think you broke something.

The zero means that the "$sCommand=" expression has become a numeric rather than string expression.


NaasMarais
(Fresh Scripter)
2009-10-30 10:26 AM
Re: error in runnas script

ok found the problem it is below

 Code:
Enter password:
RUNNAS: The parameter is incorrect.
\\RDSJNBPEN2\netlogon\bginfo\bginfo.exe\\RDSJNBPEN2\netlogon\bginfo\rds.bgi
ERROR : Error in expression.!
Script: c:\my documents\scripts\bginfo.kix
Line  : 2

Press any key to continue . . .


NaasMarais
(Fresh Scripter)
2009-10-30 10:44 AM
Re: error in runnas script

Alright I got it to work up until this part of the code
 Code:

SHELL '%COMSPEC% /c %systemroot%\system32\runnas.exe /user:rds\loginscript "%logonserver%\netlogon\bginfo\bginfo.exe %logonserver%\netlogon\bginfo\rds.bgi" /nolicprompt /silent /timer:0'



After that I still need to add the following
 Code:
/password:itRocks@33 /env


But i am not getting it to work


Richard H.Administrator
(KiX Supporter)
2009-10-30 04:15 PM
Re: error in runnas script

"@" is a special character in KiXtart.

Either disable macros in strings with SetOption() (read the manual for more info) or double the character:
 Code:
/password:itRocks@@33