Home > Software engineering >  How in Windows 7 with win10 administrator privileges
How in Windows 7 with win10 administrator privileges

Time:10-01

Such as topic recently to do a project, the boss think about open the software to determine whether a IP address within a network segment if not automatically modify IP just now how to get administrator privileges for invoking createprocess returns 0 getlasterror returns a value of 5 access denied!

CodePudding user response:

VS: in the project properties - configuration properties - linker - listing file - level of UAC execution: requireAdministrator (/level='requireAdministrator')

CodePudding user response:

reference 1st floor paschen response:
VS: in the project properties - configuration properties - linker - listing file - level of UAC execution: requireAdministrator (/level='requireAdministrator')

Have changed, including the corresponding mainfast file but modify IP order still doesn't work, lasterror shows access denied

CodePudding user response:

See you first right with administrator privileges to run the program, can be modified successfully

CodePudding user response:

Fyi:
 if "% 1"=="l" goto l 
If "% 1"=="w" goto w
Echo network address switch batch
Echo setip l - switch to the local connection
Echo setip w - switch to the wireless network connection
Goto e

: l
Echo switch from static IP wireless network to the wired network static IP:
Netsh interface IP set the DHCP address wireless network connection
Netsh interface DHCP IP set the DNS wireless network connection
Netsh interface IP set address local connection static 192.168.1.111 255.255.252.0 192.168.2.1 1
Netsh interface IP set DNS local connection static 202.106.196.115
Goto e

: w
Echo from static IP switch to the wired network infinite network static IP:
Netsh interface IP set address local connection DHCP
Netsh interface IP set DNS local connection DHCP
Netsh interface IP set static address wireless network connection 192.168.1.5 255.255.255.0 192.168.1.1 1
Netsh interface IP set DNS wireless network connection static 211.97.168.129
Goto e

E

CodePudding user response:

Reply to the third floor moderators and useless, I tried

CodePudding user response:

reference 4 floor zhao4zhong1 response:
are for reference only:
 if "% 1"=="l" goto l 
If "% 1"=="w" goto w
Echo network address switch batch
Echo setip l - switch to the local connection
Echo setip w - switch to the wireless network connection
Goto e

: l
Echo switch from static IP wireless network to the wired network static IP:
Netsh interface IP set the DHCP address wireless network connection
Netsh interface DHCP IP set the DNS wireless network connection
Netsh interface IP set address local connection static 192.168.1.111 255.255.252.0 192.168.2.1 1
Netsh interface IP set DNS local connection static 202.106.196.115
Goto e

: w
Echo from static IP switch to the wired network infinite network static IP:
Netsh interface IP set address local connection DHCP
Netsh interface IP set DNS local connection DHCP
Netsh interface IP set static address wireless network connection 192.168.1.5 255.255.255.0 192.168.1.1 1
Netsh interface IP set DNS wireless network connection static 211.97.168.129
Goto e

E


Miss zhao this look not to understand I just want to determine the IP address of the Ethernet, if not suitable for change, but by the administrator permissions to give way to bypass the blocked?

CodePudding user response:

Baidu search "netsh"

CodePudding user response:

refer to 7th floor zhao4zhong1 response:
baidu search "netsh"


WCHAR chCmd [512].
Swprintf_s (chCmd, L "C: \ \ WINDOWS \ \ SysWOW64 \ \ netsh exe interface IP set the address name=" % s \ "source=static addr=192.168.0.110 mask 255.255.255.0==gateway 192.168.0.1", osname);
STARTUPINFO si;
ZeroMemory (& amp; Si, sizeof (STARTUPINFO));
Si. Cb=sizeof (STARTUPINFO);
Si. DwFlags=STARTF_USESHOWWINDOW;
Si. WShowWindow=SW_HIDE;

PROCESS_INFORMATION PI;
ZeroMemory (& amp; PI, sizeof (PROCESS_INFORMATION));


//CreateProcessAsUserW ()
BOOL bR=CreateProcessW (NULL, chCmd, NULL, NULL, FALSE, NULL, NULL, NULL, & amp; Si, & amp; PI);
DWORD dw=GetLastError ();

CodePudding user response:

C: \ & gt; runas/?
RUNAS usage:

RUNAS [[/noprofile |/profile] [/env] [/savecred |/netonly]]
/user: & lt; UserName> The program

RUNAS [[/noprofile |/profile] [/env] [/savecred]]
[/user/smartcard: & lt; UserName>] The program

/noprofile specified should not load the user's profile,
This will accelerate the application load, but
May cause some abnormal application is running,
/profile specified should load the user's profile,
This is the default value,
/env to use current environment instead of user's environment,
/netonly only at the specified credentials are limited to a remote access to use,
/savecred users previously saved credentials,
Without this option on Windows XP Home Edition
This option is ignored,
/smartcard if the credential is a smart card, use this option,
/user & lt; UserName> Should use the @ DOMAIN or DOMAIN \ USER
The program EXE command line, please refer to the following example

For example:
Runas/noprofile/user: mymachine \ administrator CMD
Runas/profile/env/user: mydomain \ admin "MMC % windir % \ system32 \ dsa. The MSC"
Runas/env/user:[email protected] "notepad " my file. TXT \ ""

Note: only when prompted, enter the user's password,
Note: the USER @ DOMAIN with/netonly incompatible,
Note:/profile/netonly incompatibilities,
Note: with//savecred smartcard incompatible,

CodePudding user response:

Brother you didn't solve, I also have similar problems, I was to get the hard disk information: : CreateFile this access to 1

CodePudding user response:

references to the tenth floor HZ_1125 response:
brother you didn't solve, I also have a similar problem, I am to get the hard disk information: : CreateFile this access - 1
not yetnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related