Jump to content

CMD RunAs


caramen
 Share

Recommended Posts

Hello AutoIT Helpers :) 

 

Trying to run the following as administrator but can't get it work. 

 

#include <Constants.au3>

Local $foo = Run (@ComSpec & " netcfg –v –u ms_ndiswanip", @SystemDir )


RunAs ("ACCOUNT","DOMAIN.com","PASSWORD",@ComSpec & " netcfg –v –u ms_ndiswanip" , @SystemDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD)

 

Seem like i'm missing something. 

 

Run and RunAs are not working. 

 

If i read the line it return me 0 Like if the command does not got rights I guess.

 

If i run manualy the command in a CMD runed as administrator it s working. Just want to do that at end.

 

Guess there is somthing special in this command. 

 

For information i got a 64 bits OS

The " netcfg –v –u ms_ndiswanip "

When i look into system32 I  have netcfg.exe But i dont got it in Syswow64

 

The strange thing is if i run manualy my cmd as admin. It will execute the syswow64 cmd. And then i will be able to execute my netcfg from there. §There is somthing i cant figure out. PLease help me :) 

 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

  • Moderators

So what do you see when you add "/k " to your run or runAs command, to keep the window open?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Developers
9 minutes ago, JLogan3o13 said:

So what do you see when you add "/k " to your run or runAs command, to keep the window open?

/c is missing totally so no surprise it doesn't work.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

You have the command to run, in the RunAs function, in the Logon_flag parameter position as well, so no wonder it won't work that way.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I paste that code but i tryed lot of syntaxt./  sorry it was unclear

 

Hmmmm 

Run (@ComSpec & " /c /k netcfg –v –u ms_ndiswanip", @SystemDir ) ;Not working (window disapear directly
RunAs ("Administrateur",@ComputerName,"***",$RUN_LOGON_PROFILE,@ComSpec & " /c /k netcfg –v –u ms_ndiswanip" , @SystemDir);Not working at all
Run (@ComSpec & " /k netcfg –v –u ms_ndiswanip", @SystemDir ) ;Working ( BUT no command sent ) 
RunAs ("Administrateur",@ComputerName,"***",$RUN_LOGON_PROFILE,@ComSpec & " /k netcfg –v –u ms_ndiswanip" , @SystemDir); Working ( BUT no command sent )

 

I dodge the problem like that but i whould prefer somthing more reliable. with less windows opened and as possible hidden. 

RunAs("Administrateur",@ComputerName,"SgtChewie38",$RUN_LOGON_PROFILE,"c:\windows\syswow64\cmd.exe", @SystemDir, @SW_SHOW)
   $cHNW = WinWait ("c:\windows")
   Send ("runas /user:Administrateur cmd")
   Send("{ENTER}")
   Sleep(300)
   Send ("***");Password
   Send("{ENTER}")
   Sleep(300)
   $cHNW2 = WinWait ("cmd (en tant")
   Send ("netcfg.exe -v -u ms_ndiswanipV6")
   Send ("{ENTER}")
   Sleep(1000)
   Send ("netcfg.exe -v -u ms_ndiswanip")
   Send ("{ENTER}")
   Sleep (1000)

Then i need the @comspec. 

 

 

When i run the command manualy ( i got white cmd so dont be suprised ) But that show it run it from different accuont?.

5 Lines in total

image.png.f29907e77981ca0de5d9239d68b37a91.png

 

Terminé mean in this case "sucess"

But this is when i run from autoIT

4 lines total

image.png.2123a09893faefe99e07b5c7d888264e.png

Nothing sent to me. I am hightligthing the line between the two c:\ to be sure it s not black text. But nothing. I cant even see if it s sucess or fail or ... 

 

Btw the black console does not seem to be admin.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

25 minutes ago, Nine said:

Run (@ComSpec & " /c netcfg –v –u ms_ndiswanip", @SystemDir ) 

Try this line ...

$cDisk = RunAs ("Administrateur",@ComputerName,"SgtChewie38",$RUN_LOGON_PROFILE,@ComSpec & "/k /c netcfg –v –u ms_ndiswanip", @SystemDir ,$STDERR_CHILD + $STDOUT_CHILD )

;Nothing Window disapeard so i cannot check if it 's succed
Run (@ComSpec & "/k /c netcfg –v –u ms_ndiswanip", @SystemDir  ) ; /C is'nt a recognised command
Run ( @ComSpec & " /c netcfg –v –u ms_ndiswanip", @SystemDir  ) ; Not admin and cant check

µTryed same with show flag = same

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Link to comment
Share on other sites

Trying tomorow. Good way for testing ty. 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

16 hours ago, Nine said:

Run (@ComSpec & "  /c netcfg.exe –v –u ms_ndiswanip > test.txt" , ""  ) 

compiled it and runned the exe as an admin, result will be in test.txt

Text.txt = blank

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

1 minute ago, Jos said:

Try running it in X64 mode. 

Jos

 

just to be sure... you mean compil it in x64? 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

  • Developers

Either compile as x64 or run it with AutoIt3_x64.exe. Use the AutoIt3Wrapper directive when you have the full version of SciTE4AutoIt3 installed.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

3 minutes ago, Jos said:

Either compile as x64 or run it with AutoIt3_x64.exe. Use the AutoIt3Wrapper directive when you have the full version of SciTE4AutoIt3 installed.

Jos

Nothing change it s same the txt file is blank.

Btw..i do not changed the code actually i run this : 

Run (@ComSpec & "  /c netcfg.exe –v –u ms_ndiswanip > test.txt" , ""  )

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

I guess it is the netcfg tool that is realy special.

 

I dont know how to manage it. Should I give up automatig it this way ?

 

Btw everyone cant test out the script since that command disabling IP V6&Wan settings nothing else. 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

  • Developers

Ok, i understand now what the issue is. The pasted code it UTF8 encoded which causes some issues.
Try this line: 

Run (@ComSpec & " /k netcfg.exe -v -q ms_ndiswanip > test.txt 2>&1" )

.. and check by changing the File Encoding to Ansi ( File/Encoding/Code Page Property

2 hours ago, caramen said:

Btw everyone cant test out the script since that command disabling IP V6&Wan settings nothing else. 

I replaced the -u with -q so it only does a Query ...safer? ;) 

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

14 minutes ago, Jos said:

I replaced the -u with -q so it only does a Query ...safer? ;) 

I have to test if it repeiring my vpn issue still. I have to reproduce the bug and test the line i ll need some time i come back here. Thx Jos for spending time for me. 

 

Just for my understanding. 

15 minutes ago, Jos said:

The pasted code it UTF8 encoded which causes some issues.

That mean it s the Forum page that show the text in UTF8 ? and if i copy past it s uncorrect then ? Or can you explain me ?

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

  • Developers

Just do what I stated in my post:

17 minutes ago, Jos said:

.. and check by changing the File Encoding to Ansi ( File/Encoding/Code Page Property

When I use your posted code in SciTE and run it, I have the same issue. So when I change the encoding i see:

Quote

Run (@ComSpec & " /c netcfg.exe –v –u ms_ndiswanip > test.txt")

So that means that the "-v -u" are UTF doublebyte characters in stead of ANSI characters. CHange them to ANSI Characters and try your script again.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Well i dont need to reproduce bug it wont work with the -q

I mean the query in'nt enouth to solve the wanted thing.

I tested with -u and it's working :D

test.txt output : 

Tentative de d‚sinstallation de ms_ndiswanip ...


... Termin.

 

Same as :

image.png

 

Now @Jos

Could you explain me if i encode all my script like that will it change somthing ? 

Or it 's better to compile and run from external executable ?

 

I am total newby in encoding... And ansi things.. i dont even know what is that i ll document myself.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

  • Developers
3 minutes ago, caramen said:

Could you explain me if i encode all my script like that will it change somthing ? 

No need to change the encoding from utf8 (without BOM) to ANSI, but make sure you use ANSI characters on the commandline for Run().
Somewhere in the process the encoding gets lost, but I am not sure why it happens. Somebody will be able to tell us I am sure. :)

Jos
 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...