Jump to content

Why this script does not work at startup unless i execute it with double click ?


Recommended Posts

tonycst what makes no sense is you claiming your script work.  You have a function called _Connect() which contains two RunWait command.   Replaced the RunWait() for a ConsoleWrite() and you get the following syntax:

  • C:\Windows\system32\cmd.exe" /C NET USE N: /DELETE
  • C:\Windows\system32\cmd.exe" /K NET USE N: 192.168.1.1

The second NET USE command is invalid syntax and you always will get the message "System error 67 has occurred.  The network name cannot be found."  Your net use command is missing the \\ and a \sharename so it will never work.

Quote

net use [{devicename | *}] [\\computername\sharename[\volume] [{password | *}]] [/user:[domainname\]username] [/user:[dotteddomainname\]username] [/user:[username@dotteddomainname] [/home {devicename | *} [{password | *}]] [/persistent:{yes | no}] [/smartcard] [/savecred] [/delete] [/help] [/?]

Here is some links for you to read

How To Read Command Syntax   Take a look example #3 Net Use Command

Net Use Command Line 

If you want to prove me wrong just open command prompt and type NET USE N: 192.168.1.1 press enter, then post the screen shot.

 

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

  • Replies 65
  • Created
  • Last Reply

Top Posters In This Topic

5 hours ago, Danny35d said:

tonycst what makes no sense is you claiming your script work.  You have a function called _Connect() which contains two RunWait command.   Replaced the RunWait() for a ConsoleWrite() and you get the following syntax:

  • C:\Windows\system32\cmd.exe" /C NET USE N: /DELETE
  • C:\Windows\system32\cmd.exe" /K NET USE N: 192.168.1.1

The second NET USE command is invalid syntax and you always will get the message "System error 67 has occurred.  The network name cannot be found."  Your net use command is missing the \\ and a \sharename so it will never work.

Here is some links for you to read

How To Read Command Syntax   Take a look example #3 Net Use Command

Net Use Command Line 

If you want to prove me wrong just open command prompt and type NET USE N: 192.168.1.1 press enter, then post the screen shot.

 

Dude, the command is correct. If wold not get my network drive connected if it was not. Forget about the command PLEASE, its not the issue. Issue is how its executed.

Plus, i cant use 192.168.1.1, it wont connect anywhere (its a router specific thing. Some routers will connect to network drive like that some wont.)

Problem is not the command, but how script is executed. Get that into your head please and stop pointing it out.

Link to comment
Share on other sites

  • Developers

There that attitude again .. Do you seriously think it will help you in any way?

By the way... I did post a suggestion for a test which you completely ignored ...so wondering what you are expecting?

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

This just make me remember the fable about the Swallow teaching the Sparrow how to make his Nest. At the end the Swallow get tired because the Sparrow look like already know every step and then the Swallow go away and this is why the Sparrow make such a mess of nest.

 

Link to comment
Share on other sites

I'm not sure if this issue has been resolved or not, and I am not about to read all of the posts concerning already suggested fixes.  What I will tell you is that if your script requires Admin credentials to execute, that would explain why it is not running.  the only way to execute elevated commands at startup is by using the Event viewer in Administration tools to call the executable at startup.  Hope this helps.

Link to comment
Share on other sites

On 4/8/2016 at 11:00 AM, Jos said:

There that attitude again .. Do you seriously think it will help you in any way?

By the way... I did post a suggestion for a test which you completely ignored ...so wondering what you are expecting?

Jos

I ignore you because i did what you said and it returned 0 and 1 but you did not reply to my result so.......
 

 

On 4/8/2016 at 0:33 PM, MattHiggs said:

I'm not sure if this issue has been resolved or not, and I am not about to read all of the posts concerning already suggested fixes.  What I will tell you is that if your script requires Admin credentials to execute, that would explain why it is not running.  the only way to execute elevated commands at startup is by using the Event viewer in Administration tools to call the executable at startup.  Hope this helps.

Username is "Administrator" not "Tony" with administrative privileges.

Event viewer is a viewer, not an execution tool.

 

Problem is at the execution level and how autoit passes it down to either OS or the CPU its self (i dont know).

All i know is it does not work when ran from registry but works from startup folder. What difference does it make other then the execution process ? Therefore problem is as the execution level.

 

I keep talking about execution and all i get back is "your command is incorrect" or "you need to use event viewer" or "i told you already" and "change your attitude"

Im not stupid to accept stupid solutions, so i will keep my attitude regardless of the outcome. i stick to my guns just like anyone here does blaming my code being wrong or my not being administrator or me having an attitude.

Let that bug live, i dont care,its your bug, not mine.

One day i told Bank of America that there was a fisher who got hundreds of people information stole thru fishing emails and that i was able to read his files and access online accounts based on information i dug out of his server.

They never replied because they were just as dumb as some people here ignoring the issue autoit has.

 

In the case of the Bank, i later learned that fishers are part of them, and they work for them. But in the case of autoit, my logic does not see an explanation why bug can be ignored just because some smart ass with an attitude presents it.

Link to comment
Share on other sites

@tonycst let put you out of your misery and arrogance and attitude before @Jos do it or closed this and maybe ban you from the Forum.

From here: Difference Between Run Registry Key and Startup Folder

The Start menu is designed to start shortcuts of programs when you log in for convenience (user-level), whereas the Run registry is to start programs that are meant to run no matter what (even if you don't want them to) (system-level).

From Here: How to make elevated programs recognize network drives
Here you will realize why is not working your NET USE to map your desire share.

Another WHY here: Mapped-Drives-Not-Accessible-Until-User-Opens-Network-Share-Explorer

Another Possible WHY here: Net-Use-Mapping-Not-Working-in-Batch-Files-but-works-in-cmd

Another WHY here: Missing-Network-Drives

People here was trying to help you but you don't listen and I suspect you are not even thinking due your attitude.

Note: I hope you at least be honest and post here if this work for you, if you try it of course because maybe you already know is not going to work without trying.

Kind Regards
Alien

Link to comment
Share on other sites

  • Developers
2 hours ago, tonycst said:

I ignore you because i did what you said and it returned 0 and 1 but you did not reply to my result so.

Are you sure?

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

Test 1
No network drive connected.
User executed script
Return:
ShellExecute:
2
0
Result: Network drive connected

Test 2
No network drive connected
Script executed via registry
Return:
ShellExecute:
0
2
Result:Nothing connected

Pretty sure that stands for "i tried"
In the past it returned 0 and 1 but now its 0 and 2 (not working either way unless executed by a user)

Edited by tonycst
Link to comment
Share on other sites

Please understand ALL OF YOU that the problem IS NOT the network drive or the command or the script, problem is autoit not executing it right.

I have issues running allot of scripts from registry, this is just the simplest to demonstrate.

I have issues importing or exporting registry keys when script executed from registry.
 

Code as simple as:

RunWait(@WindowsDir & "\regedit.exe /S " & $RegFile) ;File to registry
Fails to run at start up when script is executed via registry key. It gives path errors as if it does not know that the regfile is right next to the script.

Adding @scriptdir does not help. Adding #RequireAdmin does not help (kinda does when user is just a user with administrative previledges but is not working when user is Administrator)
 

Its not the script problem. Perhaps my OS is lacking something ?

Link to comment
Share on other sites

  • Developers
1 hour ago, tonycst said:

Pretty sure that stands for "i tried"

is this the result of the test requested here?: 

This test will exclude the AutoIt internals as that will simply shell the created Bat file at login time. I would appreciate when you calm down a little and post a little less in attack mode. All people responded are trying to help you and you aren't being to appreciative about it. 

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

Lets have a look at your example:

RunWait(@WindowsDir & "\regedit.exe /S " & $RegFile)

Where is $RegFile ? Keep in mind that the Administrator account or any other accounts don't have access to all folders. So if you try:

RunWait(@WindowsDir & "\regedit.exe /S C:\test.reg")

Even better for test purposes to try:

RunWait("C:\windows\regedit.exe /S C:\test.reg")

What is the result ?

Link to comment
Share on other sites

@tonycst

First and most important:
- I create a Virtual Machine just for doing this and finish this.
- Windows 7 x64 factory default, only change made was Activate Administrator Account.

I change your Script to look like this(note small change adding \\ because is needed and also add "\share" because as far as I know you can't MAP an IP ADDRESS you need a share path name to be mapped after that IP address):

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Devcom-Network-Wifi-modem-Vista.ico
#AutoIt3Wrapper_Outfile=Network Drive Startup.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
$Address = FileReadLine ("Address.txt",1)
If $Address = "" Then
    FileDelete ("Address.txt")
    FileWrite ("Address.txt","10.0.2.2" & @CRLF & "Avobe address is used to connect to network drive")
    MsgBox (16,"Error","No valid address was found." & @CRLF & "New Address.txt file was written. Please edit it for correct address and restart this application.")
    Exit
EndIf
$Gui = GUICreate ("Network Drive Startup",200,100)
$TimeoutInput = GUICtrlCreateInput ("3000",10,20,190,20)
$AddressInput = GUICtrlCreateInput ($Address,10,40,190,20)
GUISetState (@SW_SHOW)
Sleep (GUICtrlRead ($TimeoutInput))
$Start = TimerInit()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    $Timeout = GUICtrlRead ($TimeoutInput)
    $AddresstoPing = "10.0.2.2"
    $Difference = TimerDiff($Start)
    If $Difference > $Timeout then Exit
    $Ping = Ping ($AddresstoPing)
    If $Ping > 0 Then
        _Connect()
    EndIf
WEnd
Func _Connect()

    RunWait('"' & @ComSpec & '" /C NET USE N: /DELETE', '', @SW_SHOW)
    RunWait('"' & @ComSpec & '" /C NET USE N: ' & '\\'&$Address&'\share', '', @SW_SHOW)
    RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Network Drive StartUp","REG_SZ",@ScriptFullPath)
    Exit
EndFunc



Test #1:
- Run your code and the RegWrite ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Network Drive StartUp","REG_SZ",@ScriptFullPath) line does nothing. So I add this by hand to the registry.

Test #2:
- Restart the System and got error because the script can't locate Address.txt and the script create Address.txt under this path: C:\Windows\SysWOW64\
(This is because you don't specified the full path in your code to Address.txt)

Test #3:
- Restart the System again and everything work as it should because the Script could read the previous Address.txt create under C:\Windows\SysWOW64\

So now is up to you if you try the solution or just keep saying is not working and is an AutoIt problem.

Regards
Alien.


 

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...