runas does not work when there are spaces in the path name on 1 pc

A

acem77

%windir%\System32\runas.exe /user:main\user-admin "C:\Documents and
Settings\user\Desktop\Mega_admin_tool.bat"

Error I get
193: C:\Documents and Settings\user\Desktop\Mega_admin_tool.bat is not a v
alid Win32 application.

I used this to run a batch file as an admin on multiple pcs in the domain.

It has work for many months but all of a sudden today it stopped working on
the main work station I use every day.

I can log on to any other pc in the domain and it work fine.
If I use a new path with no space it works fine.
I use the " " to get it to work with spaces. But on the one pc it does not
help any...

It is not a profile problem as it does not follow my account.

I check all the environment variables and compared them to settings on other
pcs that do work.

I am out of ideas...does anyone have any suggestions??

Thanks
 
B

blank

%windir%\System32\runas.exe /user:main\user-admin "C:\Documents and
Settings\user\Desktop\Mega_admin_tool.bat"

Error I get
193: C:\Documents and Settings\user\Desktop\Mega_admin_tool.bat is not
a v alid Win32 application.

I used this to run a batch file as an admin on multiple pcs in the
domain.

It has work for many months but all of a sudden today it stopped
working on the main work station I use every day.

I can log on to any other pc in the domain and it work fine.
If I use a new path with no space it works fine.
I use the " " to get it to work with spaces. But on the one pc it does
not help any...

It is not a profile problem as it does not follow my account.

I check all the environment variables and compared them to settings on
other pcs that do work.

I am out of ideas...does anyone have any suggestions??

Thanks

What happens if you do just:

"C:\Documents and Settings\user\Desktop\Mega_admin_tool.bat"

(i.e. without the runas stuff)

How about if you add cmd.exe /c into the line to explicitly use cmd.exe
to execute the batch file - what happens then? - note the outer pair of
quotes and inner pair of \" (the quotes in your original example with a
backslash added to escape them) - between the *** is all one line:

***
%windir%\System32\runas.exe /user:main\user-admin "%windir%\System32
\cmd.exe /c \"C:\Documents and Settings\user\Desktop\Mega_admin_tool.bat
\""
***

And finally, try using the following line to set %test% to the short
version of your path:

***
for %i in ("C:\Documents and Settings\user\Desktop\Mega_admin_tool.bat")
do set test=%~sfi
***

and then try:

%windir%\System32\runas.exe /user:main\user-admin %test%


Check your filetype associations for .bat files:
assoc .bat
(should get the answer: .bat=batfile )
ftype batfile
(should get the answer: batfile="%1" %*

Check if .cmd is similar (try renaming your .bat to .cmd)
 
J

John Wunderlich

%windir%\System32\runas.exe /user:main\user-admin "C:\Documents and
Settings\user\Desktop\Mega_admin_tool.bat"

Error I get
193: C:\Documents and Settings\user\Desktop\Mega_admin_tool.bat is
not a v alid Win32 application.

I used this to run a batch file as an admin on multiple pcs in the
domain.

It has work for many months but all of a sudden today it stopped
working on the main work station I use every day.

I can log on to any other pc in the domain and it work fine.
If I use a new path with no space it works fine.
I use the " " to get it to work with spaces. But on the one pc it
does not help any...

It is not a profile problem as it does not follow my account.

I check all the environment variables and compared them to
settings on other pcs that do work.

I am out of ideas...does anyone have any suggestions??

Thanks

Alternate approach:
You could go with the "8.3" file/directory names...
"Documents and Settings" can often be replaced with "docume~1" which
doesn't contain any spaces. (In a command prompt window, enter the
command:
dir /x \
to be sure).

HTH,
John
 
A

acem77

Thanks for the feed back both of the above ideas work if spaces are removed.
so far this proves this workstation does not like spaces in the dir paths.
if the path has more than 8 characters with no spaces it still works. So its
not a 8.3 issue But it does help part of the problem.

These paths work
"C:\DOCUME~1\user12~1\Desktop\MEGA_A~1.BAT"
"C:\DOCUME~1\user123456789\Desktop\Mega_admin_tool.bat"
Does not work.
"C:\Documents and Settings\user\Desktop\Mega_admin_tool.bat"

file type associations all check out.

There must be something in XP that tells the OS how to handle spaces in a
dir path and that must have been changed/corrupted.

For now I have a work around.

It would be cool to find out what has really happened.
In the end ill most likely re-image the workstation.
 
J

John John (MVP)

acem77 said:
Thanks for the feed back both of the above ideas work if spaces are removed.
so far this proves this workstation does not like spaces in the dir paths.
if the path has more than 8 characters with no spaces it still works. So its
not a 8.3 issue But it does help part of the problem.

These paths work
"C:\DOCUME~1\user12~1\Desktop\MEGA_A~1.BAT"
"C:\DOCUME~1\user123456789\Desktop\Mega_admin_tool.bat"
Does not work.
"C:\Documents and Settings\user\Desktop\Mega_admin_tool.bat"

The commands are not run in the same path at all, are you sure that the
file is in the C:\Documents and Settings\user\... folder? The file
appears to be in the \user123456789\... folder.

John
 
A

acem77

John John (MVP) said:
The commands are not run in the same path at all, are you sure that the
file is in the C:\Documents and Settings\user\... folder? The file
appears to be in the \user123456789\... folder.

John

Sorry my bad "user" is always the same folder. it was just made for this
post.
"C:\Documents and Settings\user123456789\Desktop\Mega_admin_tool.bat"
 
A

acem77

Bill Blanton said:
Just for the h of it, try wrapping it in two sets of quotes.

Though the following was written in regards to the Service control manager, it
might give a clue-
http://support.microsoft.com/kb/812486

I tried 2 sets of quotes it will not even function.(even then it would just
be a work around just for the heck of it i wounder what is causing this pc to
behave this way)
the MS solutions sounds like the right direction but i do not know what
service to try it on or seen any that look right. there must be some reg
setting that got corrupt.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top