Sign in to follow this  
Followers 0
inm101

Why can't I be a Standard User to run this program?

8 posts in this topic

This program attempts to copy a file from a shared drive, if the copy fails it looks to copy the file from somewhere else. I've found that I have to be an Administrator on the PC for the program to run correctly. I need to be able to run it as a Standard User without using the "Run As" function.

Any ideas?

P.S. If you're wondering why I'm not using Drive Map Add it's because I've never been able to successfully use it.

;Put this program in the user startup!
;This Program will copy and launch the XP Login
;This is for Tablets and PCs


$dir = "C:\documents and settings\"& @UserName &"\my documents\sso\"

RunWait(@ComSpec & " /c net use * /delete /y", "", @SW_HIDE)
Sleep (1000)
$server1 = "123.45.67.891"
$server2 = "123.45.67.892"

;First map drive to server1
$run = RunWait(@ComSpec & " /c net use x: \\"& $server1 &"\usercheck /user:domain\username ""password""", "", @SW_HIDE)
ConsoleWrite("0 = success ** $run = " & $run & @CRLF)
;Try to copy the file
$FC = FileCopy("X:\XPLogin.exe",$dir & "XPLogin.exe",1)
ConsoleWrite("1 = success ** $fc = " & $FC & @CRLF)

;if the copy fails
if $fc = 0 then ;if can't copy file then try to copy from server2
;Map drive to server2
$run = RunWait(@ComSpec & " /c net use R: \\"& $server2 &"\folder\folder\folder /user:domain\username ""password""", "", @SW_HIDE)
ConsoleWrite("0 = success ** $run2 = " & $run & @CRLF)
$FC = FileCopy("R:\XPLogin.exe",$dir & "XPLogin.exe",1)
ConsoleWrite("1 = success ** $fc2 = " & $FC & @CRLF)
EndIf
Sleep (1000)

;Run the copied file
Run("C:\XPLogin.exe", @WindowsDir, @SW_MAXIMIZE)

Exit

Share this post


Link to post
Share on other sites



Try putting #RequireAdmin at the top of your script.

Also

$dir = "C:\documents and settings\"& @UserName &"\my documents\sso\"

would be better as

$dir = @MyDocumentsDir & "\sso\"

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

So you can't copy from a mapped drive when you use net.exe and you can't get DriveMapAdd() to work. Did you not stop and think for two seconds that maybe the user you are using doesn't have the rights to access the drive *or* that mapping a drive requires administrative rights? I'm certain it's one of those two conditions. So copy the file directly from the share if you really do have access to the share, otherwise if you must map the drive then you will need to do so as an admin using #RequireAdmin or RunAs().

Edited by Valik

Share this post


Link to post
Share on other sites

So you can't copy from a mapped drive when you use net.exe and you can't get DriveMapAdd() to work. Did you not stop and think for two seconds that maybe the user you are using doesn't have the rights to access the drive *or* that mapping a drive requires administrative rights? I'm certain it's one of those two conditions. So copy the file directly from the share if you really do have access to the share, otherwise if you must map the drive then you will need to do so as an admin using #RequireAdmin or RunAs().

You are a brash Russian Valik! :) Yes, I have thought for two seconds about the user's access to the drive. The thing is, is that I can run a net use command and map a drive with the same user I'm trying to run the program with (a standard user).

I'm not understanding why it works via commandline, but doesn't work via AutoIT as the same user.

Also, I will change it GEOSoft to the shorter path. Thank you.

Share this post


Link to post
Share on other sites

You are a brash Russian Valik! :)

Where exactly does anything ever say I'm Russian?

Yes, I have thought for two seconds about the user's access to the drive. The thing is, is that I can run a net use command and map a drive with the same user I'm trying to run the program with (a standard user).

I'm not understanding why it works via commandline, but doesn't work via AutoIT as the same user.

Then why didn't you say that? Your post makes it read as if nothing at all works. Not that your example works but DriveMapAdd() does not.

Share this post


Link to post
Share on other sites

After further investigation, I don't believe the problem is mapping the drive. I believe the problem is trying to copy the file from X: to the "My Documents\sso" folder. I think it has to do with the spacing between the words "Documents and Settings". What's the best way around that?

Share this post


Link to post
Share on other sites

Nevermind, I changed it to this and now it works:

$FC = FileCopy("X:\XPLogin.exe",@MyDocumentsDir & "\sso\XPLogin.exe",1)

Thank you!

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I think it has to do with the spacing between the words "Documents and Settings". What's the best way around that?

I'm not sure you heading down the right path if that's giving you issues, but this will give you 'short' paths...

FileGetShortName("C:\Documents and settings\SSO") ; Would now look like C:\DOCU~\...etc...

Edit: Just in time not to help! ack... o.0

Edited by BinaryBrother

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